Aart Bik | d14c595 | 2015-09-08 15:25:15 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
Vladimir Marko | e272715 | 2019-10-10 10:46:42 +0100 | [diff] [blame^] | 20 | #include "base/macros.h" |
Aart Bik | d14c595 | 2015-09-08 15:25:15 -0700 | [diff] [blame] | 21 | #include "induction_var_analysis.h" |
| 22 | |
Vladimir Marko | e272715 | 2019-10-10 10:46:42 +0100 | [diff] [blame^] | 23 | namespace art HIDDEN { |
Aart Bik | d14c595 | 2015-09-08 15:25:15 -0700 | [diff] [blame] | 24 | |
| 25 | /** |
Aart Bik | b3365e0 | 2015-09-21 14:45:05 -0700 | [diff] [blame] | 26 | * This class implements range analysis on expressions within loops. It takes the results |
| 27 | * of induction variable analysis in the constructor and provides a public API to obtain |
Aart Bik | 8e02e3e | 2017-02-28 14:41:55 -0800 | [diff] [blame] | 28 | * a conservative lower and upper bound value or last value on each instruction in the HIR. |
| 29 | * The public API also provides a few general-purpose utility methods related to induction. |
Aart Bik | d14c595 | 2015-09-08 15:25:15 -0700 | [diff] [blame] | 30 | * |
Aart Bik | b3365e0 | 2015-09-21 14:45:05 -0700 | [diff] [blame] | 31 | * The range analysis is done with a combination of symbolic and partial integral evaluation |
| 32 | * of expressions. The analysis avoids complications with wrap-around arithmetic on the integral |
| 33 | * parts but all clients should be aware that wrap-around may occur on any of the symbolic parts. |
| 34 | * For example, given a known range for [0,100] for i, the evaluation yields range [-100,100] |
| 35 | * for expression -2*i+100, which is exact, and range [x,x+100] for expression i+x, which may |
| 36 | * wrap-around anywhere in the range depending on the actual value of x. |
Aart Bik | d14c595 | 2015-09-08 15:25:15 -0700 | [diff] [blame] | 37 | */ |
| 38 | class InductionVarRange { |
| 39 | public: |
| 40 | /* |
| 41 | * A value that can be represented as "a * instruction + b" for 32-bit constants, where |
Aart Bik | b3365e0 | 2015-09-21 14:45:05 -0700 | [diff] [blame] | 42 | * Value() denotes an unknown lower and upper bound. Although range analysis could yield |
| 43 | * more complex values, the format is sufficiently powerful to represent useful cases |
| 44 | * and feeds directly into optimizations like bounds check elimination. |
Aart Bik | d14c595 | 2015-09-08 15:25:15 -0700 | [diff] [blame] | 45 | */ |
| 46 | struct Value { |
Aart Bik | b3365e0 | 2015-09-21 14:45:05 -0700 | [diff] [blame] | 47 | Value() : instruction(nullptr), a_constant(0), b_constant(0), is_known(false) {} |
Aart Bik | d14c595 | 2015-09-08 15:25:15 -0700 | [diff] [blame] | 48 | Value(HInstruction* i, int32_t a, int32_t b) |
Aart Bik | b3365e0 | 2015-09-21 14:45:05 -0700 | [diff] [blame] | 49 | : instruction(a != 0 ? i : nullptr), a_constant(a), b_constant(b), is_known(true) {} |
Aart Bik | d14c595 | 2015-09-08 15:25:15 -0700 | [diff] [blame] | 50 | explicit Value(int32_t b) : Value(nullptr, 0, b) {} |
Aart Bik | b3365e0 | 2015-09-21 14:45:05 -0700 | [diff] [blame] | 51 | // Representation as: a_constant x instruction + b_constant. |
Aart Bik | d14c595 | 2015-09-08 15:25:15 -0700 | [diff] [blame] | 52 | HInstruction* instruction; |
| 53 | int32_t a_constant; |
| 54 | int32_t b_constant; |
Aart Bik | b3365e0 | 2015-09-21 14:45:05 -0700 | [diff] [blame] | 55 | // If true, represented by prior fields. Otherwise unknown value. |
| 56 | bool is_known; |
Aart Bik | d14c595 | 2015-09-08 15:25:15 -0700 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | explicit InductionVarRange(HInductionVarAnalysis* induction); |
| 60 | |
| 61 | /** |
Aart Bik | 52be7e7 | 2016-06-23 11:20:41 -0700 | [diff] [blame] | 62 | * Given a context denoted by the first instruction, returns a possibly conservative lower |
| 63 | * and upper bound on the instruction's value in the output parameters min_val and max_val, |
| 64 | * respectively. The need_finite_test flag denotes if an additional finite-test is needed |
| 65 | * to protect the range evaluation inside its loop. The parameter chase_hint defines an |
| 66 | * instruction at which chasing may stop. Returns false on failure. |
Aart Bik | d14c595 | 2015-09-08 15:25:15 -0700 | [diff] [blame] | 67 | */ |
Aart Bik | 1fc3afb | 2016-02-02 13:26:16 -0800 | [diff] [blame] | 68 | bool GetInductionRange(HInstruction* context, |
Aart Bik | 389b3db | 2015-10-28 14:23:40 -0700 | [diff] [blame] | 69 | HInstruction* instruction, |
Aart Bik | 52be7e7 | 2016-06-23 11:20:41 -0700 | [diff] [blame] | 70 | HInstruction* chase_hint, |
Aart Bik | 1fc3afb | 2016-02-02 13:26:16 -0800 | [diff] [blame] | 71 | /*out*/ Value* min_val, |
| 72 | /*out*/ Value* max_val, |
| 73 | /*out*/ bool* needs_finite_test); |
Aart Bik | d14c595 | 2015-09-08 15:25:15 -0700 | [diff] [blame] | 74 | |
| 75 | /** |
Aart Bik | 389b3db | 2015-10-28 14:23:40 -0700 | [diff] [blame] | 76 | * Returns true if range analysis is able to generate code for the lower and upper |
| 77 | * bound expressions on the instruction in the given context. The need_finite_test |
| 78 | * and need_taken test flags denote if an additional finite-test and/or taken-test |
| 79 | * are needed to protect the range evaluation inside its loop. |
Aart Bik | d14c595 | 2015-09-08 15:25:15 -0700 | [diff] [blame] | 80 | */ |
Aart Bik | 16d3a65 | 2016-09-09 10:33:50 -0700 | [diff] [blame] | 81 | bool CanGenerateRange(HInstruction* context, |
| 82 | HInstruction* instruction, |
| 83 | /*out*/ bool* needs_finite_test, |
| 84 | /*out*/ bool* needs_taken_test); |
Aart Bik | aec3cce | 2015-10-14 17:44:55 -0700 | [diff] [blame] | 85 | |
| 86 | /** |
| 87 | * Generates the actual code in the HIR for the lower and upper bound expressions on the |
| 88 | * instruction in the given context. Code for the lower and upper bound expression are |
Aart Bik | 389b3db | 2015-10-28 14:23:40 -0700 | [diff] [blame] | 89 | * generated in given block and graph and are returned in the output parameters lower and |
| 90 | * upper, respectively. For a loop invariant, lower is not set. |
Aart Bik | aec3cce | 2015-10-14 17:44:55 -0700 | [diff] [blame] | 91 | * |
| 92 | * For example, given expression x+i with range [0, 5] for i, calling this method |
| 93 | * will generate the following sequence: |
| 94 | * |
| 95 | * block: |
| 96 | * lower: add x, 0 |
| 97 | * upper: add x, 5 |
Aart Bik | 389b3db | 2015-10-28 14:23:40 -0700 | [diff] [blame] | 98 | * |
Aart Bik | 16d3a65 | 2016-09-09 10:33:50 -0700 | [diff] [blame] | 99 | * Precondition: CanGenerateRange() returns true. |
Aart Bik | aec3cce | 2015-10-14 17:44:55 -0700 | [diff] [blame] | 100 | */ |
Aart Bik | 16d3a65 | 2016-09-09 10:33:50 -0700 | [diff] [blame] | 101 | void GenerateRange(HInstruction* context, |
| 102 | HInstruction* instruction, |
| 103 | HGraph* graph, |
| 104 | HBasicBlock* block, |
| 105 | /*out*/ HInstruction** lower, |
| 106 | /*out*/ HInstruction** upper); |
Aart Bik | 389b3db | 2015-10-28 14:23:40 -0700 | [diff] [blame] | 107 | |
| 108 | /** |
| 109 | * Generates explicit taken-test for the loop in the given context. Code is generated in |
Aart Bik | 16d3a65 | 2016-09-09 10:33:50 -0700 | [diff] [blame] | 110 | * given block and graph. Returns generated taken-test. |
Aart Bik | 389b3db | 2015-10-28 14:23:40 -0700 | [diff] [blame] | 111 | * |
Aart Bik | 16d3a65 | 2016-09-09 10:33:50 -0700 | [diff] [blame] | 112 | * Precondition: CanGenerateRange() returns true and needs_taken_test is set. |
Aart Bik | 389b3db | 2015-10-28 14:23:40 -0700 | [diff] [blame] | 113 | */ |
Aart Bik | 16d3a65 | 2016-09-09 10:33:50 -0700 | [diff] [blame] | 114 | HInstruction* GenerateTakenTest(HInstruction* context, HGraph* graph, HBasicBlock* block); |
| 115 | |
| 116 | /** |
| 117 | * Returns true if induction analysis is able to generate code for last value of |
| 118 | * the given instruction inside the closest enveloping loop. |
| 119 | */ |
| 120 | bool CanGenerateLastValue(HInstruction* instruction); |
| 121 | |
| 122 | /** |
| 123 | * Generates last value of the given instruction in the closest enveloping loop. |
| 124 | * Code is generated in given block and graph. Returns generated last value. |
| 125 | * |
| 126 | * Precondition: CanGenerateLastValue() returns true. |
| 127 | */ |
| 128 | HInstruction* GenerateLastValue(HInstruction* instruction, HGraph* graph, HBasicBlock* block); |
| 129 | |
| 130 | /** |
| 131 | * Updates all matching fetches with the given replacement in all induction information |
| 132 | * that is associated with the given instruction. |
| 133 | */ |
| 134 | void Replace(HInstruction* instruction, HInstruction* fetch, HInstruction* replacement); |
Aart Bik | aec3cce | 2015-10-14 17:44:55 -0700 | [diff] [blame] | 135 | |
Aart Bik | 482095d | 2016-10-10 15:39:10 -0700 | [diff] [blame] | 136 | /** |
| 137 | * Incrementally updates induction information for just the given loop. |
| 138 | */ |
| 139 | void ReVisit(HLoopInformation* loop) { |
| 140 | induction_analysis_->induction_.erase(loop); |
Aart Bik | cc42be0 | 2016-10-20 16:14:16 -0700 | [diff] [blame] | 141 | for (HInstructionIterator it(loop->GetHeader()->GetPhis()); !it.Done(); it.Advance()) { |
| 142 | induction_analysis_->cycles_.erase(it.Current()->AsPhi()); |
| 143 | } |
Aart Bik | 482095d | 2016-10-10 15:39:10 -0700 | [diff] [blame] | 144 | induction_analysis_->VisitLoop(loop); |
| 145 | } |
| 146 | |
Aart Bik | 9abf894 | 2016-10-14 09:49:42 -0700 | [diff] [blame] | 147 | /** |
Aart Bik | cc42be0 | 2016-10-20 16:14:16 -0700 | [diff] [blame] | 148 | * Lookup an interesting cycle associated with an entry phi. |
| 149 | */ |
| 150 | ArenaSet<HInstruction*>* LookupCycle(HPhi* phi) const { |
| 151 | return induction_analysis_->LookupCycle(phi); |
| 152 | } |
| 153 | |
| 154 | /** |
Aart Bik | b29f684 | 2017-07-28 15:58:41 -0700 | [diff] [blame] | 155 | * Checks if the given phi instruction has been classified as anything by |
| 156 | * induction variable analysis. Returns false for anything that cannot be |
| 157 | * classified statically, such as reductions or other complex cycles. |
| 158 | */ |
| 159 | bool IsClassified(HPhi* phi) const { |
| 160 | HLoopInformation* lp = phi->GetBlock()->GetLoopInformation(); // closest enveloping loop |
| 161 | return (lp != nullptr) && (induction_analysis_->LookupInfo(lp, phi) != nullptr); |
| 162 | } |
| 163 | |
| 164 | /** |
Artem Serov | 121f203 | 2017-10-23 19:19:06 +0100 | [diff] [blame] | 165 | * Checks if header logic of a loop terminates. If trip count is known sets 'trip_count' to its |
| 166 | * value. |
Aart Bik | 9abf894 | 2016-10-14 09:49:42 -0700 | [diff] [blame] | 167 | */ |
Artem Serov | 121f203 | 2017-10-23 19:19:06 +0100 | [diff] [blame] | 168 | bool IsFinite(HLoopInformation* loop, /*out*/ int64_t* trip_count) const; |
| 169 | |
| 170 | /** |
| 171 | * Checks if a trip count is known for the loop and sets 'trip_count' to its value in this case. |
| 172 | */ |
| 173 | bool HasKnownTripCount(HLoopInformation* loop, /*out*/ int64_t* trip_count) const; |
Aart Bik | 9abf894 | 2016-10-14 09:49:42 -0700 | [diff] [blame] | 174 | |
Aart Bik | 8e02e3e | 2017-02-28 14:41:55 -0800 | [diff] [blame] | 175 | /** |
Aart Bik | fa76296 | 2017-04-07 11:33:37 -0700 | [diff] [blame] | 176 | * Checks if the given instruction is a unit stride induction inside the closest enveloping |
| 177 | * loop of the context that is defined by the first parameter (e.g. pass an array reference |
| 178 | * as context and the index as instruction to make sure the stride is tested against the |
| 179 | * loop that envelops the reference the closest). Returns invariant offset on success. |
Aart Bik | 8e02e3e | 2017-02-28 14:41:55 -0800 | [diff] [blame] | 180 | */ |
Aart Bik | fa76296 | 2017-04-07 11:33:37 -0700 | [diff] [blame] | 181 | bool IsUnitStride(HInstruction* context, |
| 182 | HInstruction* instruction, |
Aart Bik | 37dc4df | 2017-06-28 14:08:00 -0700 | [diff] [blame] | 183 | HGraph* graph, |
Aart Bik | fa76296 | 2017-04-07 11:33:37 -0700 | [diff] [blame] | 184 | /*out*/ HInstruction** offset) const; |
Aart Bik | 8e02e3e | 2017-02-28 14:41:55 -0800 | [diff] [blame] | 185 | |
| 186 | /** |
| 187 | * Generates the trip count expression for the given loop. Code is generated in given block |
| 188 | * and graph. The expression is guarded by a taken test if needed. Returns the trip count |
| 189 | * expression on success or null otherwise. |
| 190 | */ |
| 191 | HInstruction* GenerateTripCount(HLoopInformation* loop, HGraph* graph, HBasicBlock* block); |
| 192 | |
Aart Bik | d14c595 | 2015-09-08 15:25:15 -0700 | [diff] [blame] | 193 | private: |
Aart Bik | 97412c92 | 2016-02-19 20:14:38 -0800 | [diff] [blame] | 194 | /* |
| 195 | * Enum used in IsConstant() request. |
| 196 | */ |
| 197 | enum ConstantRequest { |
| 198 | kExact, |
| 199 | kAtMost, |
| 200 | kAtLeast |
| 201 | }; |
| 202 | |
| 203 | /** |
Artem Serov | 121f203 | 2017-10-23 19:19:06 +0100 | [diff] [blame] | 204 | * Checks if header logic of a loop terminates. If trip count is known (constant) sets |
| 205 | * 'is_constant' to true and 'trip_count' to the trip count value. |
| 206 | */ |
| 207 | bool CheckForFiniteAndConstantProps(HLoopInformation* loop, |
| 208 | /*out*/ bool* is_constant, |
| 209 | /*out*/ int64_t* trip_count) const; |
| 210 | |
| 211 | /** |
Aart Bik | 97412c92 | 2016-02-19 20:14:38 -0800 | [diff] [blame] | 212 | * Returns true if exact or upper/lower bound on the given induction |
| 213 | * information is known as a 64-bit constant, which is returned in value. |
| 214 | */ |
| 215 | bool IsConstant(HInductionVarAnalysis::InductionInfo* info, |
| 216 | ConstantRequest request, |
Aart Bik | 52be7e7 | 2016-06-23 11:20:41 -0700 | [diff] [blame] | 217 | /*out*/ int64_t* value) const; |
Aart Bik | 97412c92 | 2016-02-19 20:14:38 -0800 | [diff] [blame] | 218 | |
Aart Bik | 52be7e7 | 2016-06-23 11:20:41 -0700 | [diff] [blame] | 219 | /** Returns whether induction information can be obtained. */ |
| 220 | bool HasInductionInfo(HInstruction* context, |
| 221 | HInstruction* instruction, |
| 222 | /*out*/ HLoopInformation** loop, |
| 223 | /*out*/ HInductionVarAnalysis::InductionInfo** info, |
| 224 | /*out*/ HInductionVarAnalysis::InductionInfo** trip) const; |
| 225 | |
| 226 | bool HasFetchInLoop(HInductionVarAnalysis::InductionInfo* info) const; |
Aart Bik | 16d3a65 | 2016-09-09 10:33:50 -0700 | [diff] [blame] | 227 | bool NeedsTripCount(HInductionVarAnalysis::InductionInfo* info, |
| 228 | /*out*/ int64_t* stride_value) const; |
Aart Bik | 7d57d7f | 2015-12-09 14:39:48 -0800 | [diff] [blame] | 229 | bool IsBodyTripCount(HInductionVarAnalysis::InductionInfo* trip) const; |
| 230 | bool IsUnsafeTripCount(HInductionVarAnalysis::InductionInfo* trip) const; |
Aart Bik | 52be7e7 | 2016-06-23 11:20:41 -0700 | [diff] [blame] | 231 | bool IsWellBehavedTripCount(HInductionVarAnalysis::InductionInfo* trip) const; |
Aart Bik | d14c595 | 2015-09-08 15:25:15 -0700 | [diff] [blame] | 232 | |
Aart Bik | 7d57d7f | 2015-12-09 14:39:48 -0800 | [diff] [blame] | 233 | Value GetLinear(HInductionVarAnalysis::InductionInfo* info, |
| 234 | HInductionVarAnalysis::InductionInfo* trip, |
| 235 | bool in_body, |
| 236 | bool is_min) const; |
Aart Bik | df7822e | 2016-12-06 10:05:30 -0800 | [diff] [blame] | 237 | Value GetPolynomial(HInductionVarAnalysis::InductionInfo* info, |
| 238 | HInductionVarAnalysis::InductionInfo* trip, |
| 239 | bool in_body, |
| 240 | bool is_min) const; |
Aart Bik | c071a01 | 2016-12-01 10:22:31 -0800 | [diff] [blame] | 241 | Value GetGeometric(HInductionVarAnalysis::InductionInfo* info, |
| 242 | HInductionVarAnalysis::InductionInfo* trip, |
| 243 | bool in_body, |
| 244 | bool is_min) const; |
Aart Bik | 7d57d7f | 2015-12-09 14:39:48 -0800 | [diff] [blame] | 245 | Value GetFetch(HInstruction* instruction, |
| 246 | HInductionVarAnalysis::InductionInfo* trip, |
| 247 | bool in_body, |
| 248 | bool is_min) const; |
| 249 | Value GetVal(HInductionVarAnalysis::InductionInfo* info, |
| 250 | HInductionVarAnalysis::InductionInfo* trip, |
| 251 | bool in_body, |
| 252 | bool is_min) const; |
| 253 | Value GetMul(HInductionVarAnalysis::InductionInfo* info1, |
| 254 | HInductionVarAnalysis::InductionInfo* info2, |
| 255 | HInductionVarAnalysis::InductionInfo* trip, |
| 256 | bool in_body, |
| 257 | bool is_min) const; |
| 258 | Value GetDiv(HInductionVarAnalysis::InductionInfo* info1, |
| 259 | HInductionVarAnalysis::InductionInfo* info2, |
| 260 | HInductionVarAnalysis::InductionInfo* trip, |
| 261 | bool in_body, |
| 262 | bool is_min) const; |
Aart Bik | df7822e | 2016-12-06 10:05:30 -0800 | [diff] [blame] | 263 | Value GetRem(HInductionVarAnalysis::InductionInfo* info1, |
| 264 | HInductionVarAnalysis::InductionInfo* info2) const; |
Aart Bik | 7dc9693 | 2016-10-12 10:01:05 -0700 | [diff] [blame] | 265 | Value GetXor(HInductionVarAnalysis::InductionInfo* info1, |
| 266 | HInductionVarAnalysis::InductionInfo* info2) const; |
Aart Bik | d14c595 | 2015-09-08 15:25:15 -0700 | [diff] [blame] | 267 | |
Aart Bik | 52be7e7 | 2016-06-23 11:20:41 -0700 | [diff] [blame] | 268 | Value MulRangeAndConstant(int64_t value, |
| 269 | HInductionVarAnalysis::InductionInfo* info, |
| 270 | HInductionVarAnalysis::InductionInfo* trip, |
| 271 | bool in_body, |
| 272 | bool is_min) const; |
| 273 | Value DivRangeAndConstant(int64_t value, |
| 274 | HInductionVarAnalysis::InductionInfo* info, |
| 275 | HInductionVarAnalysis::InductionInfo* trip, |
| 276 | bool in_body, |
| 277 | bool is_min) const; |
Aart Bik | d14c595 | 2015-09-08 15:25:15 -0700 | [diff] [blame] | 278 | |
Aart Bik | 7d57d7f | 2015-12-09 14:39:48 -0800 | [diff] [blame] | 279 | Value AddValue(Value v1, Value v2) const; |
| 280 | Value SubValue(Value v1, Value v2) const; |
| 281 | Value MulValue(Value v1, Value v2) const; |
| 282 | Value DivValue(Value v1, Value v2) const; |
| 283 | Value MergeVal(Value v1, Value v2, bool is_min) const; |
Aart Bik | d14c595 | 2015-09-08 15:25:15 -0700 | [diff] [blame] | 284 | |
Aart Bik | aec3cce | 2015-10-14 17:44:55 -0700 | [diff] [blame] | 285 | /** |
Aart Bik | 16d3a65 | 2016-09-09 10:33:50 -0700 | [diff] [blame] | 286 | * Generates code for lower/upper/taken-test or last value in the HIR. Returns true on |
| 287 | * success. With values nullptr, the method can be used to determine if code generation |
Aart Bik | aec3cce | 2015-10-14 17:44:55 -0700 | [diff] [blame] | 288 | * would be successful without generating actual code yet. |
| 289 | */ |
Aart Bik | 9abf894 | 2016-10-14 09:49:42 -0700 | [diff] [blame] | 290 | bool GenerateRangeOrLastValue(HInstruction* context, |
| 291 | HInstruction* instruction, |
| 292 | bool is_last_val, |
| 293 | HGraph* graph, |
| 294 | HBasicBlock* block, |
| 295 | /*out*/ HInstruction** lower, |
| 296 | /*out*/ HInstruction** upper, |
| 297 | /*out*/ HInstruction** taken_test, |
| 298 | /*out*/ int64_t* stride_value, |
| 299 | /*out*/ bool* needs_finite_test, |
| 300 | /*out*/ bool* needs_taken_test) const; |
| 301 | |
Aart Bik | df7822e | 2016-12-06 10:05:30 -0800 | [diff] [blame] | 302 | bool GenerateLastValuePolynomial(HInductionVarAnalysis::InductionInfo* info, |
| 303 | HInductionVarAnalysis::InductionInfo* trip, |
| 304 | HGraph* graph, |
| 305 | HBasicBlock* block, |
| 306 | /*out*/HInstruction** result) const; |
| 307 | |
Aart Bik | c071a01 | 2016-12-01 10:22:31 -0800 | [diff] [blame] | 308 | bool GenerateLastValueGeometric(HInductionVarAnalysis::InductionInfo* info, |
| 309 | HInductionVarAnalysis::InductionInfo* trip, |
| 310 | HGraph* graph, |
| 311 | HBasicBlock* block, |
| 312 | /*out*/HInstruction** result) const; |
| 313 | |
Aart Bik | df7822e | 2016-12-06 10:05:30 -0800 | [diff] [blame] | 314 | bool GenerateLastValueWrapAround(HInductionVarAnalysis::InductionInfo* info, |
| 315 | HInductionVarAnalysis::InductionInfo* trip, |
| 316 | HGraph* graph, |
| 317 | HBasicBlock* block, |
| 318 | /*out*/HInstruction** result) const; |
| 319 | |
Aart Bik | 9abf894 | 2016-10-14 09:49:42 -0700 | [diff] [blame] | 320 | bool GenerateLastValuePeriodic(HInductionVarAnalysis::InductionInfo* info, |
| 321 | HInductionVarAnalysis::InductionInfo* trip, |
| 322 | HGraph* graph, |
| 323 | HBasicBlock* block, |
| 324 | /*out*/HInstruction** result, |
| 325 | /*out*/ bool* needs_taken_test) const; |
Aart Bik | aec3cce | 2015-10-14 17:44:55 -0700 | [diff] [blame] | 326 | |
Aart Bik | 7d57d7f | 2015-12-09 14:39:48 -0800 | [diff] [blame] | 327 | bool GenerateCode(HInductionVarAnalysis::InductionInfo* info, |
| 328 | HInductionVarAnalysis::InductionInfo* trip, |
| 329 | HGraph* graph, |
| 330 | HBasicBlock* block, |
Aart Bik | 1fc3afb | 2016-02-02 13:26:16 -0800 | [diff] [blame] | 331 | /*out*/ HInstruction** result, |
Aart Bik | 7d57d7f | 2015-12-09 14:39:48 -0800 | [diff] [blame] | 332 | bool in_body, |
| 333 | bool is_min) const; |
Aart Bik | aec3cce | 2015-10-14 17:44:55 -0700 | [diff] [blame] | 334 | |
Aart Bik | 16d3a65 | 2016-09-09 10:33:50 -0700 | [diff] [blame] | 335 | void ReplaceInduction(HInductionVarAnalysis::InductionInfo* info, |
| 336 | HInstruction* fetch, |
| 337 | HInstruction* replacement); |
| 338 | |
Aart Bik | d14c595 | 2015-09-08 15:25:15 -0700 | [diff] [blame] | 339 | /** Results of prior induction variable analysis. */ |
Aart Bik | 52be7e7 | 2016-06-23 11:20:41 -0700 | [diff] [blame] | 340 | HInductionVarAnalysis* induction_analysis_; |
| 341 | |
| 342 | /** Instruction at which chasing may stop. */ |
| 343 | HInstruction* chase_hint_; |
Aart Bik | d14c595 | 2015-09-08 15:25:15 -0700 | [diff] [blame] | 344 | |
Aart Bik | 22af3be | 2015-09-10 12:50:58 -0700 | [diff] [blame] | 345 | friend class HInductionVarAnalysis; |
Aart Bik | d14c595 | 2015-09-08 15:25:15 -0700 | [diff] [blame] | 346 | friend class InductionVarRangeTest; |
| 347 | |
| 348 | DISALLOW_COPY_AND_ASSIGN(InductionVarRange); |
| 349 | }; |
| 350 | |
| 351 | } // namespace art |
| 352 | |
| 353 | #endif // ART_COMPILER_OPTIMIZING_INDUCTION_VAR_RANGE_H_ |