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
diff --git a/compiler/optimizing/loop_optimization.cc b/compiler/optimizing/loop_optimization.cc
index 12b180d..6c76ab8 100644
--- a/compiler/optimizing/loop_optimization.cc
+++ b/compiler/optimizing/loop_optimization.cc
@@ -426,10 +426,12 @@
}
// 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 @@
// 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 @@
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 @@
// 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);