blob: 6555bc220674f07b3ca136a78d6f1031980d4191 [file] [log] [blame]
Aart Bikd14c5952015-09-08 15:25:15 -07001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ART_COMPILER_OPTIMIZING_INDUCTION_VAR_RANGE_H_
18#define ART_COMPILER_OPTIMIZING_INDUCTION_VAR_RANGE_H_
19
20#include "induction_var_analysis.h"
21
Vladimir Marko0a516052019-10-14 13:00:44 +000022namespace art {
Aart Bikd14c5952015-09-08 15:25:15 -070023
24/**
Aart Bikb3365e02015-09-21 14:45:05 -070025 * This class implements range analysis on expressions within loops. It takes the results
26 * of induction variable analysis in the constructor and provides a public API to obtain
Aart Bik8e02e3e2017-02-28 14:41:55 -080027 * a conservative lower and upper bound value or last value on each instruction in the HIR.
28 * The public API also provides a few general-purpose utility methods related to induction.
Aart Bikd14c5952015-09-08 15:25:15 -070029 *
Aart Bikb3365e02015-09-21 14:45:05 -070030 * The range analysis is done with a combination of symbolic and partial integral evaluation
31 * of expressions. The analysis avoids complications with wrap-around arithmetic on the integral
32 * parts but all clients should be aware that wrap-around may occur on any of the symbolic parts.
33 * For example, given a known range for [0,100] for i, the evaluation yields range [-100,100]
34 * for expression -2*i+100, which is exact, and range [x,x+100] for expression i+x, which may
35 * wrap-around anywhere in the range depending on the actual value of x.
Aart Bikd14c5952015-09-08 15:25:15 -070036 */
37class InductionVarRange {
38 public:
39 /*
40 * A value that can be represented as "a * instruction + b" for 32-bit constants, where
Aart Bikb3365e02015-09-21 14:45:05 -070041 * Value() denotes an unknown lower and upper bound. Although range analysis could yield
42 * more complex values, the format is sufficiently powerful to represent useful cases
43 * and feeds directly into optimizations like bounds check elimination.
Aart Bikd14c5952015-09-08 15:25:15 -070044 */
45 struct Value {
Aart Bikb3365e02015-09-21 14:45:05 -070046 Value() : instruction(nullptr), a_constant(0), b_constant(0), is_known(false) {}
Aart Bikd14c5952015-09-08 15:25:15 -070047 Value(HInstruction* i, int32_t a, int32_t b)
Aart Bikb3365e02015-09-21 14:45:05 -070048 : instruction(a != 0 ? i : nullptr), a_constant(a), b_constant(b), is_known(true) {}
Aart Bikd14c5952015-09-08 15:25:15 -070049 explicit Value(int32_t b) : Value(nullptr, 0, b) {}
Aart Bikb3365e02015-09-21 14:45:05 -070050 // Representation as: a_constant x instruction + b_constant.
Aart Bikd14c5952015-09-08 15:25:15 -070051 HInstruction* instruction;
52 int32_t a_constant;
53 int32_t b_constant;
Aart Bikb3365e02015-09-21 14:45:05 -070054 // If true, represented by prior fields. Otherwise unknown value.
55 bool is_known;
Aart Bikd14c5952015-09-08 15:25:15 -070056 };
57
58 explicit InductionVarRange(HInductionVarAnalysis* induction);
59
60 /**
Vladimir Marko8d100ba2022-03-04 10:13:10 +000061 * Given a context block, returns a possibly conservative lower
Aart Bik52be7e72016-06-23 11:20:41 -070062 * and upper bound on the instruction's value in the output parameters min_val and max_val,
63 * respectively. The need_finite_test flag denotes if an additional finite-test is needed
64 * to protect the range evaluation inside its loop. The parameter chase_hint defines an
65 * instruction at which chasing may stop. Returns false on failure.
Aart Bikd14c5952015-09-08 15:25:15 -070066 */
Vladimir Marko8d100ba2022-03-04 10:13:10 +000067 bool GetInductionRange(const HBasicBlock* context,
Aart Bik389b3db2015-10-28 14:23:40 -070068 HInstruction* instruction,
Aart Bik52be7e72016-06-23 11:20:41 -070069 HInstruction* chase_hint,
Aart Bik1fc3afb2016-02-02 13:26:16 -080070 /*out*/ Value* min_val,
71 /*out*/ Value* max_val,
72 /*out*/ bool* needs_finite_test);
Aart Bikd14c5952015-09-08 15:25:15 -070073
74 /**
Aart Bik389b3db2015-10-28 14:23:40 -070075 * Returns true if range analysis is able to generate code for the lower and upper
76 * bound expressions on the instruction in the given context. The need_finite_test
77 * and need_taken test flags denote if an additional finite-test and/or taken-test
78 * are needed to protect the range evaluation inside its loop.
Aart Bikd14c5952015-09-08 15:25:15 -070079 */
Vladimir Marko8d100ba2022-03-04 10:13:10 +000080 bool CanGenerateRange(const HBasicBlock* context,
Aart Bik16d3a652016-09-09 10:33:50 -070081 HInstruction* instruction,
82 /*out*/ bool* needs_finite_test,
83 /*out*/ bool* needs_taken_test);
Aart Bikaec3cce2015-10-14 17:44:55 -070084
85 /**
86 * Generates the actual code in the HIR for the lower and upper bound expressions on the
87 * instruction in the given context. Code for the lower and upper bound expression are
Aart Bik389b3db2015-10-28 14:23:40 -070088 * generated in given block and graph and are returned in the output parameters lower and
89 * upper, respectively. For a loop invariant, lower is not set.
Aart Bikaec3cce2015-10-14 17:44:55 -070090 *
91 * For example, given expression x+i with range [0, 5] for i, calling this method
92 * will generate the following sequence:
93 *
94 * block:
95 * lower: add x, 0
96 * upper: add x, 5
Aart Bik389b3db2015-10-28 14:23:40 -070097 *
Aart Bik16d3a652016-09-09 10:33:50 -070098 * Precondition: CanGenerateRange() returns true.
Aart Bikaec3cce2015-10-14 17:44:55 -070099 */
Vladimir Marko8d100ba2022-03-04 10:13:10 +0000100 void GenerateRange(const HBasicBlock* context,
Aart Bik16d3a652016-09-09 10:33:50 -0700101 HInstruction* instruction,
102 HGraph* graph,
103 HBasicBlock* block,
104 /*out*/ HInstruction** lower,
105 /*out*/ HInstruction** upper);
Aart Bik389b3db2015-10-28 14:23:40 -0700106
107 /**
Vladimir Marko8d100ba2022-03-04 10:13:10 +0000108 * Generates explicit taken-test for the given `loop_control` instruction. Code is generated in
Aart Bik16d3a652016-09-09 10:33:50 -0700109 * given block and graph. Returns generated taken-test.
Aart Bik389b3db2015-10-28 14:23:40 -0700110 *
Aart Bik16d3a652016-09-09 10:33:50 -0700111 * Precondition: CanGenerateRange() returns true and needs_taken_test is set.
Aart Bik389b3db2015-10-28 14:23:40 -0700112 */
Vladimir Marko8d100ba2022-03-04 10:13:10 +0000113 HInstruction* GenerateTakenTest(HInstruction* loop_control, HGraph* graph, HBasicBlock* block);
Aart Bik16d3a652016-09-09 10:33:50 -0700114
115 /**
116 * Returns true if induction analysis is able to generate code for last value of
117 * the given instruction inside the closest enveloping loop.
118 */
119 bool CanGenerateLastValue(HInstruction* instruction);
120
121 /**
122 * Generates last value of the given instruction in the closest enveloping loop.
123 * Code is generated in given block and graph. Returns generated last value.
124 *
125 * Precondition: CanGenerateLastValue() returns true.
126 */
127 HInstruction* GenerateLastValue(HInstruction* instruction, HGraph* graph, HBasicBlock* block);
128
129 /**
130 * Updates all matching fetches with the given replacement in all induction information
131 * that is associated with the given instruction.
132 */
133 void Replace(HInstruction* instruction, HInstruction* fetch, HInstruction* replacement);
Aart Bikaec3cce2015-10-14 17:44:55 -0700134
Aart Bik482095d2016-10-10 15:39:10 -0700135 /**
136 * Incrementally updates induction information for just the given loop.
137 */
Vladimir Marko8d100ba2022-03-04 10:13:10 +0000138 void ReVisit(const HLoopInformation* loop) {
Aart Bik482095d2016-10-10 15:39:10 -0700139 induction_analysis_->induction_.erase(loop);
Aart Bikcc42be02016-10-20 16:14:16 -0700140 for (HInstructionIterator it(loop->GetHeader()->GetPhis()); !it.Done(); it.Advance()) {
141 induction_analysis_->cycles_.erase(it.Current()->AsPhi());
142 }
Aart Bik482095d2016-10-10 15:39:10 -0700143 induction_analysis_->VisitLoop(loop);
144 }
145
Aart Bik9abf8942016-10-14 09:49:42 -0700146 /**
Aart Bikcc42be02016-10-20 16:14:16 -0700147 * Lookup an interesting cycle associated with an entry phi.
148 */
149 ArenaSet<HInstruction*>* LookupCycle(HPhi* phi) const {
150 return induction_analysis_->LookupCycle(phi);
151 }
152
153 /**
Aart Bikb29f6842017-07-28 15:58:41 -0700154 * Checks if the given phi instruction has been classified as anything by
155 * induction variable analysis. Returns false for anything that cannot be
156 * classified statically, such as reductions or other complex cycles.
157 */
158 bool IsClassified(HPhi* phi) const {
159 HLoopInformation* lp = phi->GetBlock()->GetLoopInformation(); // closest enveloping loop
160 return (lp != nullptr) && (induction_analysis_->LookupInfo(lp, phi) != nullptr);
161 }
162
163 /**
Artem Serov121f2032017-10-23 19:19:06 +0100164 * Checks if header logic of a loop terminates. If trip count is known sets 'trip_count' to its
165 * value.
Aart Bik9abf8942016-10-14 09:49:42 -0700166 */
Vladimir Marko8d100ba2022-03-04 10:13:10 +0000167 bool IsFinite(const HLoopInformation* loop, /*out*/ int64_t* trip_count) const;
Artem Serov121f2032017-10-23 19:19:06 +0100168
169 /**
170 * Checks if a trip count is known for the loop and sets 'trip_count' to its value in this case.
171 */
Vladimir Marko8d100ba2022-03-04 10:13:10 +0000172 bool HasKnownTripCount(const HLoopInformation* loop, /*out*/ int64_t* trip_count) const;
Aart Bik9abf8942016-10-14 09:49:42 -0700173
Aart Bik8e02e3e2017-02-28 14:41:55 -0800174 /**
Aart Bikfa762962017-04-07 11:33:37 -0700175 * Checks if the given instruction is a unit stride induction inside the closest enveloping
176 * loop of the context that is defined by the first parameter (e.g. pass an array reference
177 * as context and the index as instruction to make sure the stride is tested against the
178 * loop that envelops the reference the closest). Returns invariant offset on success.
Aart Bik8e02e3e2017-02-28 14:41:55 -0800179 */
Vladimir Marko8d100ba2022-03-04 10:13:10 +0000180 bool IsUnitStride(const HBasicBlock* context,
Aart Bikfa762962017-04-07 11:33:37 -0700181 HInstruction* instruction,
Aart Bik37dc4df2017-06-28 14:08:00 -0700182 HGraph* graph,
Aart Bikfa762962017-04-07 11:33:37 -0700183 /*out*/ HInstruction** offset) const;
Aart Bik8e02e3e2017-02-28 14:41:55 -0800184
185 /**
186 * Generates the trip count expression for the given loop. Code is generated in given block
187 * and graph. The expression is guarded by a taken test if needed. Returns the trip count
188 * expression on success or null otherwise.
189 */
Vladimir Marko8d100ba2022-03-04 10:13:10 +0000190 HInstruction* GenerateTripCount(const HLoopInformation* loop, HGraph* graph, HBasicBlock* block);
Aart Bik8e02e3e2017-02-28 14:41:55 -0800191
Aart Bikd14c5952015-09-08 15:25:15 -0700192 private:
Aart Bik97412c922016-02-19 20:14:38 -0800193 /*
194 * Enum used in IsConstant() request.
195 */
196 enum ConstantRequest {
197 kExact,
198 kAtMost,
199 kAtLeast
200 };
201
202 /**
Artem Serov121f2032017-10-23 19:19:06 +0100203 * Checks if header logic of a loop terminates. If trip count is known (constant) sets
204 * 'is_constant' to true and 'trip_count' to the trip count value.
205 */
Vladimir Marko8d100ba2022-03-04 10:13:10 +0000206 bool CheckForFiniteAndConstantProps(const HLoopInformation* loop,
Artem Serov121f2032017-10-23 19:19:06 +0100207 /*out*/ bool* is_constant,
208 /*out*/ int64_t* trip_count) const;
209
210 /**
Aart Bik97412c922016-02-19 20:14:38 -0800211 * Returns true if exact or upper/lower bound on the given induction
212 * information is known as a 64-bit constant, which is returned in value.
213 */
Vladimir Marko8d100ba2022-03-04 10:13:10 +0000214 bool IsConstant(const HBasicBlock* context,
215 const HLoopInformation* loop,
216 HInductionVarAnalysis::InductionInfo* info,
Aart Bik97412c922016-02-19 20:14:38 -0800217 ConstantRequest request,
Aart Bik52be7e72016-06-23 11:20:41 -0700218 /*out*/ int64_t* value) const;
Aart Bik97412c922016-02-19 20:14:38 -0800219
Aart Bik52be7e72016-06-23 11:20:41 -0700220 /** Returns whether induction information can be obtained. */
Vladimir Marko8d100ba2022-03-04 10:13:10 +0000221 bool HasInductionInfo(const HBasicBlock* context,
Aart Bik52be7e72016-06-23 11:20:41 -0700222 HInstruction* instruction,
Vladimir Marko8d100ba2022-03-04 10:13:10 +0000223 /*out*/ const HLoopInformation** loop,
Aart Bik52be7e72016-06-23 11:20:41 -0700224 /*out*/ HInductionVarAnalysis::InductionInfo** info,
225 /*out*/ HInductionVarAnalysis::InductionInfo** trip) const;
226
227 bool HasFetchInLoop(HInductionVarAnalysis::InductionInfo* info) const;
Vladimir Marko8d100ba2022-03-04 10:13:10 +0000228 bool NeedsTripCount(const HBasicBlock* context,
229 const HLoopInformation* loop,
230 HInductionVarAnalysis::InductionInfo* info,
Aart Bik16d3a652016-09-09 10:33:50 -0700231 /*out*/ int64_t* stride_value) const;
Aart Bik7d57d7f2015-12-09 14:39:48 -0800232 bool IsBodyTripCount(HInductionVarAnalysis::InductionInfo* trip) const;
233 bool IsUnsafeTripCount(HInductionVarAnalysis::InductionInfo* trip) const;
Vladimir Marko8d100ba2022-03-04 10:13:10 +0000234 bool IsWellBehavedTripCount(const HBasicBlock* context,
235 const HLoopInformation* loop,
236 HInductionVarAnalysis::InductionInfo* trip) const;
Aart Bikd14c5952015-09-08 15:25:15 -0700237
Vladimir Marko8d100ba2022-03-04 10:13:10 +0000238 Value GetLinear(const HBasicBlock* context,
239 const HLoopInformation* loop,
240 HInductionVarAnalysis::InductionInfo* info,
Aart Bik7d57d7f2015-12-09 14:39:48 -0800241 HInductionVarAnalysis::InductionInfo* trip,
Aart Bik7d57d7f2015-12-09 14:39:48 -0800242 bool is_min) const;
Vladimir Marko8d100ba2022-03-04 10:13:10 +0000243 Value GetPolynomial(const HBasicBlock* context,
244 const HLoopInformation* loop,
245 HInductionVarAnalysis::InductionInfo* info,
Aart Bikdf7822e2016-12-06 10:05:30 -0800246 HInductionVarAnalysis::InductionInfo* trip,
Aart Bikdf7822e2016-12-06 10:05:30 -0800247 bool is_min) const;
Vladimir Marko8d100ba2022-03-04 10:13:10 +0000248 Value GetGeometric(const HBasicBlock* context,
249 const HLoopInformation* loop,
250 HInductionVarAnalysis::InductionInfo* info,
Aart Bikc071a012016-12-01 10:22:31 -0800251 HInductionVarAnalysis::InductionInfo* trip,
Aart Bikc071a012016-12-01 10:22:31 -0800252 bool is_min) const;
Vladimir Marko8d100ba2022-03-04 10:13:10 +0000253 Value GetFetch(const HBasicBlock* context,
254 const HLoopInformation* loop,
255 HInstruction* instruction,
Aart Bik7d57d7f2015-12-09 14:39:48 -0800256 HInductionVarAnalysis::InductionInfo* trip,
Aart Bik7d57d7f2015-12-09 14:39:48 -0800257 bool is_min) const;
Vladimir Marko8d100ba2022-03-04 10:13:10 +0000258 Value GetVal(const HBasicBlock* context,
259 const HLoopInformation* loop,
260 HInductionVarAnalysis::InductionInfo* info,
Aart Bik7d57d7f2015-12-09 14:39:48 -0800261 HInductionVarAnalysis::InductionInfo* trip,
Aart Bik7d57d7f2015-12-09 14:39:48 -0800262 bool is_min) const;
Vladimir Marko8d100ba2022-03-04 10:13:10 +0000263 Value GetMul(const HBasicBlock* context,
264 const HLoopInformation* loop,
265 HInductionVarAnalysis::InductionInfo* info1,
Aart Bik7d57d7f2015-12-09 14:39:48 -0800266 HInductionVarAnalysis::InductionInfo* info2,
267 HInductionVarAnalysis::InductionInfo* trip,
Aart Bik7d57d7f2015-12-09 14:39:48 -0800268 bool is_min) const;
Vladimir Marko8d100ba2022-03-04 10:13:10 +0000269 Value GetDiv(const HBasicBlock* context,
270 const HLoopInformation* loop,
271 HInductionVarAnalysis::InductionInfo* info1,
Aart Bik7d57d7f2015-12-09 14:39:48 -0800272 HInductionVarAnalysis::InductionInfo* info2,
273 HInductionVarAnalysis::InductionInfo* trip,
Aart Bik7d57d7f2015-12-09 14:39:48 -0800274 bool is_min) const;
Vladimir Marko8d100ba2022-03-04 10:13:10 +0000275 Value GetRem(const HBasicBlock* context,
276 const HLoopInformation* loop,
277 HInductionVarAnalysis::InductionInfo* info1,
Aart Bikdf7822e2016-12-06 10:05:30 -0800278 HInductionVarAnalysis::InductionInfo* info2) const;
Vladimir Marko8d100ba2022-03-04 10:13:10 +0000279 Value GetXor(const HBasicBlock* context,
280 const HLoopInformation* loop,
281 HInductionVarAnalysis::InductionInfo* info1,
Aart Bik7dc96932016-10-12 10:01:05 -0700282 HInductionVarAnalysis::InductionInfo* info2) const;
Aart Bikd14c5952015-09-08 15:25:15 -0700283
Vladimir Marko8d100ba2022-03-04 10:13:10 +0000284 Value MulRangeAndConstant(const HBasicBlock* context,
285 const HLoopInformation* loop,
286 int64_t value,
Aart Bik52be7e72016-06-23 11:20:41 -0700287 HInductionVarAnalysis::InductionInfo* info,
288 HInductionVarAnalysis::InductionInfo* trip,
Aart Bik52be7e72016-06-23 11:20:41 -0700289 bool is_min) const;
Vladimir Marko8d100ba2022-03-04 10:13:10 +0000290 Value DivRangeAndConstant(const HBasicBlock* context,
291 const HLoopInformation* loop,
292 int64_t value,
Aart Bik52be7e72016-06-23 11:20:41 -0700293 HInductionVarAnalysis::InductionInfo* info,
294 HInductionVarAnalysis::InductionInfo* trip,
Aart Bik52be7e72016-06-23 11:20:41 -0700295 bool is_min) const;
Aart Bikd14c5952015-09-08 15:25:15 -0700296
Aart Bik7d57d7f2015-12-09 14:39:48 -0800297 Value AddValue(Value v1, Value v2) const;
298 Value SubValue(Value v1, Value v2) const;
299 Value MulValue(Value v1, Value v2) const;
300 Value DivValue(Value v1, Value v2) const;
301 Value MergeVal(Value v1, Value v2, bool is_min) const;
Aart Bikd14c5952015-09-08 15:25:15 -0700302
Aart Bikaec3cce2015-10-14 17:44:55 -0700303 /**
Aart Bik16d3a652016-09-09 10:33:50 -0700304 * Generates code for lower/upper/taken-test or last value in the HIR. Returns true on
305 * success. With values nullptr, the method can be used to determine if code generation
Aart Bikaec3cce2015-10-14 17:44:55 -0700306 * would be successful without generating actual code yet.
307 */
Vladimir Marko8d100ba2022-03-04 10:13:10 +0000308 bool GenerateRangeOrLastValue(const HBasicBlock* context,
Aart Bik9abf8942016-10-14 09:49:42 -0700309 HInstruction* instruction,
310 bool is_last_val,
311 HGraph* graph,
312 HBasicBlock* block,
313 /*out*/ HInstruction** lower,
314 /*out*/ HInstruction** upper,
315 /*out*/ HInstruction** taken_test,
316 /*out*/ int64_t* stride_value,
317 /*out*/ bool* needs_finite_test,
318 /*out*/ bool* needs_taken_test) const;
319
Santiago Aboy Solanes4f18b942022-07-21 10:31:21 +0100320 bool GenerateLastValueLinear(const HBasicBlock* context,
321 const HLoopInformation* loop,
322 HInductionVarAnalysis::InductionInfo* info,
323 HInductionVarAnalysis::InductionInfo* trip,
324 HGraph* graph,
325 HBasicBlock* block,
326 bool is_min,
327 /*out*/ HInstruction** result) const;
328
Vladimir Marko8d100ba2022-03-04 10:13:10 +0000329 bool GenerateLastValuePolynomial(const HBasicBlock* context,
330 const HLoopInformation* loop,
331 HInductionVarAnalysis::InductionInfo* info,
Aart Bikdf7822e2016-12-06 10:05:30 -0800332 HInductionVarAnalysis::InductionInfo* trip,
333 HGraph* graph,
334 HBasicBlock* block,
335 /*out*/HInstruction** result) const;
336
Vladimir Marko8d100ba2022-03-04 10:13:10 +0000337 bool GenerateLastValueGeometric(const HBasicBlock* context,
338 const HLoopInformation* loop,
339 HInductionVarAnalysis::InductionInfo* info,
Aart Bikc071a012016-12-01 10:22:31 -0800340 HInductionVarAnalysis::InductionInfo* trip,
341 HGraph* graph,
342 HBasicBlock* block,
343 /*out*/HInstruction** result) const;
344
Vladimir Marko8d100ba2022-03-04 10:13:10 +0000345 bool GenerateLastValueWrapAround(const HBasicBlock* context,
346 const HLoopInformation* loop,
347 HInductionVarAnalysis::InductionInfo* info,
Aart Bikdf7822e2016-12-06 10:05:30 -0800348 HInductionVarAnalysis::InductionInfo* trip,
349 HGraph* graph,
350 HBasicBlock* block,
351 /*out*/HInstruction** result) const;
352
Vladimir Marko8d100ba2022-03-04 10:13:10 +0000353 bool GenerateLastValuePeriodic(const HBasicBlock* context,
354 const HLoopInformation* loop,
355 HInductionVarAnalysis::InductionInfo* info,
Aart Bik9abf8942016-10-14 09:49:42 -0700356 HInductionVarAnalysis::InductionInfo* trip,
357 HGraph* graph,
358 HBasicBlock* block,
359 /*out*/HInstruction** result,
360 /*out*/ bool* needs_taken_test) const;
Aart Bikaec3cce2015-10-14 17:44:55 -0700361
Vladimir Marko8d100ba2022-03-04 10:13:10 +0000362 bool GenerateCode(const HBasicBlock* context,
363 const HLoopInformation* loop,
364 HInductionVarAnalysis::InductionInfo* info,
Aart Bik7d57d7f2015-12-09 14:39:48 -0800365 HInductionVarAnalysis::InductionInfo* trip,
366 HGraph* graph,
367 HBasicBlock* block,
Vladimir Marko8d100ba2022-03-04 10:13:10 +0000368 bool is_min,
369 /*out*/ HInstruction** result) const;
Aart Bikaec3cce2015-10-14 17:44:55 -0700370
Aart Bik16d3a652016-09-09 10:33:50 -0700371 void ReplaceInduction(HInductionVarAnalysis::InductionInfo* info,
372 HInstruction* fetch,
373 HInstruction* replacement);
374
Aart Bikd14c5952015-09-08 15:25:15 -0700375 /** Results of prior induction variable analysis. */
Aart Bik52be7e72016-06-23 11:20:41 -0700376 HInductionVarAnalysis* induction_analysis_;
377
378 /** Instruction at which chasing may stop. */
379 HInstruction* chase_hint_;
Aart Bikd14c5952015-09-08 15:25:15 -0700380
Aart Bik22af3be2015-09-10 12:50:58 -0700381 friend class HInductionVarAnalysis;
Aart Bikd14c5952015-09-08 15:25:15 -0700382 friend class InductionVarRangeTest;
383
384 DISALLOW_COPY_AND_ASSIGN(InductionVarRange);
385};
386
387} // namespace art
388
389#endif // ART_COMPILER_OPTIMIZING_INDUCTION_VAR_RANGE_H_