diff options
author | 2023-10-25 14:34:25 +0100 | |
---|---|---|
committer | 2023-12-01 11:38:22 +0000 | |
commit | 97e5d89ca1cfe5f84d100a9546cf391d76c9f0be (patch) | |
tree | 0be44e1ebe36a2ce8e86e7db5e417ce24f189b85 | |
parent | ee12ff26f3413dee84c963af15dd1018b58466bb (diff) |
Align induction var range checks and uses
We were requiring some conditions but we weren't checking all of them.
Test: art/test/testrunner/testrunner.py --host --64 -b --optimizing
Change-Id: I7442db52492d3de2e4593152e22f4c4e2fed65b5
-rw-r--r-- | compiler/optimizing/induction_var_range.cc | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/compiler/optimizing/induction_var_range.cc b/compiler/optimizing/induction_var_range.cc index b54507a03c..8568062933 100644 --- a/compiler/optimizing/induction_var_range.cc +++ b/compiler/optimizing/induction_var_range.cc @@ -255,8 +255,8 @@ bool InductionVarRange::CanGenerateRange(const HBasicBlock* context, nullptr, // nothing generated yet &stride_value, needs_finite_test, - needs_taken_test) - && (stride_value == -1 || + needs_taken_test) && + (stride_value == -1 || stride_value == 0 || stride_value == 1); // avoid arithmetic wrap-around anomalies. } @@ -280,7 +280,10 @@ void InductionVarRange::GenerateRange(const HBasicBlock* context, nullptr, &stride_value, &b1, - &b2)) { + &b2) || + (stride_value != -1 && + stride_value != 0 && + stride_value != 1)) { LOG(FATAL) << "Failed precondition: CanGenerateRange()"; } } @@ -303,7 +306,10 @@ HInstruction* InductionVarRange::GenerateTakenTest(HInstruction* loop_control, &taken_test, &stride_value, &b1, - &b2)) { + &b2) || + (stride_value != -1 && + stride_value != 0 && + stride_value != 1)) { LOG(FATAL) << "Failed precondition: CanGenerateRange()"; } return taken_test; @@ -336,7 +342,8 @@ HInstruction* InductionVarRange::GenerateLastValue(HInstruction* instruction, HInstruction* last_value = nullptr; bool is_last_value = true; int64_t stride_value = 0; - bool b1, b2; // unused + bool needs_finite_test = false; + bool needs_taken_test = false; if (!GenerateRangeOrLastValue(context, instruction, is_last_value, @@ -346,8 +353,10 @@ HInstruction* InductionVarRange::GenerateLastValue(HInstruction* instruction, &last_value, nullptr, &stride_value, - &b1, - &b2)) { + &needs_finite_test, + &needs_taken_test) || + needs_finite_test || + needs_taken_test) { LOG(FATAL) << "Failed precondition: CanGenerateLastValue()"; } return last_value; |