Implemented trip-count safety information.
As shown in the induction analysis presentation, trip-counts need to
deal with potential taken/not-taken situations (so that trip-count
is either valid in the full loop or just in the loop-body proper)
and potential finite/infinite situations (the latter can still be
analyzed but may need to run-time test later to guard against the
infinite conditions). This CL provides that information.
Change-Id: I0445d8e836b80a3614af217ce3e39d766e77b986
diff --git a/compiler/optimizing/induction_var_analysis_test.cc b/compiler/optimizing/induction_var_analysis_test.cc
index e519e77..20492e7 100644
--- a/compiler/optimizing/induction_var_analysis_test.cc
+++ b/compiler/optimizing/induction_var_analysis_test.cc
@@ -234,7 +234,8 @@
EXPECT_STREQ("((1) * i + (1))", GetInductionInfo(increment_[0], 0).c_str());
// Trip-count.
- EXPECT_STREQ("(100)", GetInductionInfo(loop_header_[0]->GetLastInstruction(), 0).c_str());
+ EXPECT_STREQ("(TC-loop:(100))",
+ GetInductionInfo(loop_header_[0]->GetLastInstruction(), 0).c_str());
}
TEST_F(InductionVarAnalysisTest, FindDerivedInduction) {
@@ -543,8 +544,10 @@
InductionVarRange range(iva_);
InductionVarRange::Value v_min = range.GetMinInduction(store, store->InputAt(1));
InductionVarRange::Value v_max = range.GetMaxInduction(store, store->InputAt(1));
+ ASSERT_TRUE(v_min.is_known);
EXPECT_EQ(0, v_min.a_constant);
EXPECT_EQ(1, v_min.b_constant);
+ ASSERT_TRUE(v_max.is_known);
EXPECT_EQ(0, v_max.a_constant);
EXPECT_EQ(199, v_max.b_constant);
}
@@ -579,7 +582,8 @@
}
EXPECT_STREQ("((1) * i + (1))", GetInductionInfo(increment_[d], d).c_str());
// Trip-count.
- EXPECT_STREQ("(100)", GetInductionInfo(loop_header_[d]->GetLastInstruction(), d).c_str());
+ EXPECT_STREQ("(TC-loop:(100))",
+ GetInductionInfo(loop_header_[d]->GetLastInstruction(), d).c_str());
}
}