From 4a5007b02670f13ecf1bbe31625a929f94dcd3d9 Mon Sep 17 00:00:00 2001 From: Santiago Aboy Solanes Date: Fri, 17 Feb 2023 16:35:25 +0000 Subject: 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 --- compiler/optimizing/code_sinking.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'compiler/optimizing/code_sinking.cc') 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; } -- cgit v1.2.3-59-g8ed1b