From 256c94b568f35f8f23feaaf9ea0d64ed1edab1d4 Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Mon, 29 Apr 2019 10:55:09 +0100 Subject: Update induction ranges in superblock cloner. Because loop unrolling is part of a general loop optimization pass, it needs to update induction ranges as it will invalidate its instruction cache with new instructions. Bug: 131174583 Test: 696-loop Change-Id: Id3628efe316b58f69abbd9ebd43e891a8e42529f --- compiler/optimizing/loop_optimization.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'compiler/optimizing/loop_optimization.cc') diff --git a/compiler/optimizing/loop_optimization.cc b/compiler/optimizing/loop_optimization.cc index 12b180d5ff..6c76ab858b 100644 --- a/compiler/optimizing/loop_optimization.cc +++ b/compiler/optimizing/loop_optimization.cc @@ -426,10 +426,12 @@ static void TryToEvaluateIfCondition(HIf* instruction, HGraph* graph) { } // Peel the first 'count' iterations of the loop. -static void PeelByCount(HLoopInformation* loop_info, int count) { +static void PeelByCount(HLoopInformation* loop_info, + int count, + InductionVarRange* induction_range) { for (int i = 0; i < count; i++) { // Perform peeling. - PeelUnrollSimpleHelper helper(loop_info); + PeelUnrollSimpleHelper helper(loop_info, induction_range); helper.DoPeeling(); } } @@ -799,7 +801,7 @@ bool HLoopOptimization::TryUnrollingForBranchPenaltyReduction(LoopAnalysisInfo* // Perform unrolling. HLoopInformation* loop_info = analysis_info->GetLoopInfo(); - PeelUnrollSimpleHelper helper(loop_info); + PeelUnrollSimpleHelper helper(loop_info, &induction_range_); helper.DoUnrolling(); // Remove the redundant loop check after unrolling. @@ -824,7 +826,7 @@ bool HLoopOptimization::TryPeelingForLoopInvariantExitsElimination(LoopAnalysisI if (generate_code) { // Perform peeling. - PeelUnrollSimpleHelper helper(loop_info); + PeelUnrollSimpleHelper helper(loop_info, &induction_range_); helper.DoPeeling(); // Statically evaluate loop check after peeling for loop invariant condition. @@ -870,7 +872,7 @@ bool HLoopOptimization::TryFullUnrolling(LoopAnalysisInfo* analysis_info, bool g // loop_body _/ loop_body _/ // HLoopInformation* loop_info = analysis_info->GetLoopInfo(); - PeelByCount(loop_info, trip_count); + PeelByCount(loop_info, trip_count, &induction_range_); HIf* loop_hif = loop_info->GetHeader()->GetLastInstruction()->AsIf(); int32_t constant = loop_info->Contains(*loop_hif->IfTrueSuccessor()) ? 0 : 1; loop_hif->ReplaceInput(graph_->GetIntConstant(constant), 0u); -- cgit v1.2.3