summaryrefslogtreecommitdiff
path: root/compiler/optimizing/code_sinking.cc
diff options
context:
space:
mode:
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;
}