@@ -225,9 +225,9 @@ class PhiAnalyzer {
225225
226226 // Auxiliary function to calculate the number of iterations for a comparison
227227 // 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 ;
231231
232232 // Returns true if the \p Phi is an induction in the target loop. This is a
233233 // lightweight check and possible to detect an IV in some cases.
@@ -269,15 +269,13 @@ bool PhiAnalyzer::isInductionPHI(const PHINode *Phi) const {
269269 break ;
270270
271271 // Avoid infinite loop.
272- if (Visited.contains (Cur))
272+ if (! Visited.insert (Cur). second )
273273 return false ;
274274
275275 auto *I = dyn_cast<Instruction>(Cur);
276276 if (!I || !L.contains (I))
277277 return false ;
278278
279- Visited.insert (Cur);
280-
281279 if (auto *Cast = dyn_cast<CastInst>(I)) {
282280 Cur = Cast->getOperand (0 );
283281 } else if (auto *BinOp = dyn_cast<BinaryOperator>(I)) {
@@ -300,14 +298,14 @@ bool PhiAnalyzer::isInductionPHI(const PHINode *Phi) const {
300298
301299// / When either \p LHS or \p RHS is an IV, the result of \p CmpOrBinaryOp is
302300// / 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.
304302// /
305303// / If both \p LHS and \p RHS are loop-invariants, then the result of
306304// / \CmpOrBinaryOp is also a loop-invariant.
307305PhiAnalyzer::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 {
311309 auto &[LVal, LTy] = LHS;
312310 auto &[RVal, RTy] = RHS;
313311 unsigned NewVal = std::max (LVal, RVal);
@@ -380,7 +378,7 @@ PhiAnalyzer::PeelCounter PhiAnalyzer::calculate(const Value &V) {
380378 if (RHS == Unknown)
381379 return Unknown;
382380 return (IterationsToInvarianceOrInduction[I] =
383- mergeTwoCounter (*I, *LHS, *RHS));
381+ mergeTwoCounters (*I, *LHS, *RHS));
384382 }
385383 if (I->isCast ())
386384 // Cast instructions get the value of the operand.
0 commit comments