Update heuristics to compute live range of constant
- Keep constant alive for a shorter range slightly decrease dex size of
GMSCore v9 and V10 (few bytes) in release mode but it allow to decrease
the dex size for the case in the attached bug to 55324 bytes instead
of 64268 bytes in release mode and to 56380 bytes instead of 60460 bytes.
Bug: 62475297
Change-Id: I42c1cf99f44714b249c62e45efbab4ac4d7e8b26
diff --git a/src/main/java/com/android/tools/r8/ir/regalloc/LinearScanRegisterAllocator.java b/src/main/java/com/android/tools/r8/ir/regalloc/LinearScanRegisterAllocator.java
index 4bf5dc6..908e15e 100644
--- a/src/main/java/com/android/tools/r8/ir/regalloc/LinearScanRegisterAllocator.java
+++ b/src/main/java/com/android/tools/r8/ir/regalloc/LinearScanRegisterAllocator.java
@@ -1414,7 +1414,8 @@
assert spilled.isSpilled();
assert spilled.getValue().isConstant();
assert !spilled.isLinked() || spilled.isArgumentInterval();
- int maxGapSize = 50 * INSTRUCTION_NUMBER_DELTA;
+ // Do not split range if constant is reused by one of the eleven following instruction.
+ int maxGapSize = 11 * INSTRUCTION_NUMBER_DELTA;
if (!spilled.getUses().isEmpty()) {
// Split at first use after the spill position and add to unhandled to get a register
// assigned for rematerialization.