diff options
author | Mikael Peltier <mikaelpeltier@google.com> | 2017-07-04 11:29:32 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-07-04 11:29:32 +0000 |
commit | f2f49a76d0891ad58c071a872b7300af78c2de9c (patch) | |
tree | c138ed38b1e036724e9cb258d22340ef01d08bc0 /src/main/java/com/android/tools/r8/ir/regalloc | |
parent | 724be2d479f4f34dc76fcef812943f5bb3ce2914 (diff) | |
parent | 8218b6ec1976c10baefabc5927c29cac1f3ca8e6 (diff) | |
download | r8-f2f49a76d0891ad58c071a872b7300af78c2de9c.tar.gz |
Merge "Update test comparing used registers with highest register number"
Diffstat (limited to 'src/main/java/com/android/tools/r8/ir/regalloc')
-rw-r--r-- | src/main/java/com/android/tools/r8/ir/regalloc/LinearScanRegisterAllocator.java | 14 |
1 files changed, 9 insertions, 5 deletions
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 1029250bf..631f8b2a9 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 @@ -169,19 +169,19 @@ public class LinearScanRegisterAllocator implements RegisterAllocator { insertArgumentMoves(); BasicBlock[] blocks = computeLivenessInformation(); // First attempt to allocate register allowing argument reuse. This will fail if spilling - // is required or if we end up using more than 15 registers. + // is required or if we end up using more than 16 registers. boolean noSpilling = performAllocationWithoutMoveInsertion(ArgumentReuseMode.ALLOW_ARGUMENT_REUSE); - if (!noSpilling || registersUsed() > MAX_SMALL_REGISTER) { + if (!noSpilling || (highestUsedRegister() > MAX_SMALL_REGISTER)) { // Redo allocation disallowing argument reuse. This always succeeds. clearRegisterAssignments(); performAllocation(ArgumentReuseMode.DISALLOW_ARGUMENT_REUSE); } else { // Insert spill and phi moves after allocating with argument reuse. If the moves causes - // the method to use more than 15 registers we redo allocation disallowing argument + // the method to use more than 16 registers we redo allocation disallowing argument // reuse. This very rarely happens in practice (12 methods on GMSCore v4 hits that case). insertMoves(); - if (registersUsed() > MAX_SMALL_REGISTER) { + if (highestUsedRegister() > MAX_SMALL_REGISTER) { // Redo allocation disallowing argument reuse. This always succeeds. clearRegisterAssignments(); removeSpillAndPhiMoves(); @@ -399,6 +399,10 @@ public class LinearScanRegisterAllocator implements RegisterAllocator { getRegisterForValue(value, instructionNumber) + value.requiredRegisters() - 1); } + public int highestUsedRegister() { + return registersUsed() - 1; + } + @Override public int registersUsed() { int numberOfRegister = maxRegisterNumber + 1 - NUMBER_OF_SENTINEL_REGISTERS; @@ -467,7 +471,7 @@ public class LinearScanRegisterAllocator implements RegisterAllocator { assert intervals.getRegisterLimit() == Constants.U16BIT_MAX; boolean canUseArgumentRegister = true; for (LiveIntervals child : intervals.getSplitChildren()) { - if (child.getRegisterLimit() < registersUsed()) { + if (child.getRegisterLimit() < highestUsedRegister()) { canUseArgumentRegister = false; break; } |