@@ -225,9 +225,9 @@ class PhiAnalyzer {
225
225
226
226
// Auxiliary function to calculate the number of iterations for a comparison
227
227
// instruction or a binary operator.
228
- PeelCounter mergeTwoCounter (const Instruction &CmpOrBinaryOp,
229
- const PeelCounterValue &LHS,
230
- const PeelCounterValue &RHS) const ;
228
+ PeelCounter mergeTwoCounters (const Instruction &CmpOrBinaryOp,
229
+ const PeelCounterValue &LHS,
230
+ const PeelCounterValue &RHS) const ;
231
231
232
232
// Returns true if the \p Phi is an induction in the target loop. This is a
233
233
// lightweight check and possible to detect an IV in some cases.
@@ -269,15 +269,13 @@ bool PhiAnalyzer::isInductionPHI(const PHINode *Phi) const {
269
269
break ;
270
270
271
271
// Avoid infinite loop.
272
- if (Visited.contains (Cur))
272
+ if (! Visited.insert (Cur). second )
273
273
return false ;
274
274
275
275
auto *I = dyn_cast<Instruction>(Cur);
276
276
if (!I || !L.contains (I))
277
277
return false ;
278
278
279
- Visited.insert (Cur);
280
-
281
279
if (auto *Cast = dyn_cast<CastInst>(I)) {
282
280
Cur = Cast->getOperand (0 );
283
281
} else if (auto *BinOp = dyn_cast<BinaryOperator>(I)) {
@@ -300,14 +298,14 @@ bool PhiAnalyzer::isInductionPHI(const PHINode *Phi) const {
300
298
301
299
// / When either \p LHS or \p RHS is an IV, the result of \p CmpOrBinaryOp is
302
300
// / considered an IV only if it is an addition or a subtraction. Otherwise the
303
- // / result can be a value that is neither an loop-invariant nor an IV.
301
+ // / result can be a value that is neither a loop-invariant nor an IV.
304
302
// /
305
303
// / If both \p LHS and \p RHS are loop-invariants, then the result of
306
304
// / \CmpOrBinaryOp is also a loop-invariant.
307
305
PhiAnalyzer::PeelCounter
308
- PhiAnalyzer::mergeTwoCounter (const Instruction &CmpOrBinaryOp,
309
- const PeelCounterValue &LHS,
310
- const PeelCounterValue &RHS) const {
306
+ PhiAnalyzer::mergeTwoCounters (const Instruction &CmpOrBinaryOp,
307
+ const PeelCounterValue &LHS,
308
+ const PeelCounterValue &RHS) const {
311
309
auto &[LVal, LTy] = LHS;
312
310
auto &[RVal, RTy] = RHS;
313
311
unsigned NewVal = std::max (LVal, RVal);
@@ -380,7 +378,7 @@ PhiAnalyzer::PeelCounter PhiAnalyzer::calculate(const Value &V) {
380
378
if (RHS == Unknown)
381
379
return Unknown;
382
380
return (IterationsToInvarianceOrInduction[I] =
383
- mergeTwoCounter (*I, *LHS, *RHS));
381
+ mergeTwoCounters (*I, *LHS, *RHS));
384
382
}
385
383
if (I->isCast ())
386
384
// Cast instructions get the value of the operand.
0 commit comments