summaryrefslogtreecommitdiff
path: root/compiler/optimizing/code_sinking.cc
diff options
context:
space:
mode:
author Santiago Aboy Solanes <solanes@google.com> 2023-02-17 16:35:25 +0000
committer Santiago Aboy Solanes <solanes@google.com> 2023-02-23 14:15:23 +0000
commit4a5007b02670f13ecf1bbe31625a929f94dcd3d9 (patch)
tree22e3f48108ac349b80a344e26db7409dfbaa54f0 /compiler/optimizing/code_sinking.cc
parenteafc50299df5bd8ba681c5b304ae467151941cfa (diff)
Don't try to hoist an instruction out of a loop it belongs in
We can improve our code sinking heuristics to not try to hoist an instruction out of a loop it was already in. In some cases, we were successful in removing the instruction from the loop, breaking the domination. Bug: 269927803 Fixes: 269927803 Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Test: dex2oat compiling the app in the bug Change-Id: Id563a2e87798d74833081e254b2856937bdf7e2c
Diffstat (limited to 'compiler/optimizing/code_sinking.cc')
-rw-r--r--compiler/optimizing/code_sinking.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/compiler/optimizing/code_sinking.cc b/compiler/optimizing/code_sinking.cc
index 42679337b7..e7a4389ed2 100644
--- a/compiler/optimizing/code_sinking.cc
+++ b/compiler/optimizing/code_sinking.cc
@@ -171,7 +171,6 @@ static bool ShouldFilterUse(HInstruction* instruction,
return false;
}
-
// Find the ideal position for moving `instruction`. If `filter` is true,
// we filter out store instructions to that instruction, which are processed
// first in the step (3) of the sinking algorithm.
@@ -210,8 +209,10 @@ static HInstruction* FindIdealPosition(HInstruction* instruction,
return nullptr;
}
- // Move to the first dominator not in a loop, if we can.
- while (target_block->IsInLoop()) {
+ // Move to the first dominator not in a loop, if we can. We only do this if we are trying to hoist
+ // `instruction` out of a loop it wasn't a part of.
+ const HLoopInformation* loop_info = instruction->GetBlock()->GetLoopInformation();
+ while (target_block->IsInLoop() && target_block->GetLoopInformation() != loop_info) {
if (!post_dominated.IsBitSet(target_block->GetDominator()->GetBlockId())) {
break;
}