[llvm] [LoopPeel] Avoid unprofitable last iteration peeling with equalitis (PR #143588)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 12 08:56:59 PDT 2025
================
@@ -381,9 +381,23 @@ static bool shouldPeelLastIteration(Loop &L, CmpPredicate Pred,
const SCEV *ValAtSecondToLastIter = LeftAR->evaluateAtIteration(
SE.getMinusSCEV(BTC, SE.getOne(BTC->getType())), SE);
- return SE.isKnownPredicate(ICmpInst::getInversePredicate(Pred), ValAtLastIter,
- RightSCEV) &&
- SE.isKnownPredicate(Pred, ValAtSecondToLastIter, RightSCEV);
+ CmpPredicate InvPred = ICmpInst::getInversePredicate(Pred);
+ if (!SE.isKnownPredicate(InvPred, ValAtLastIter, RightSCEV) ||
+ !SE.isKnownPredicate(Pred, ValAtSecondToLastIter, RightSCEV))
+ return false;
+
+ // For a monotonic predicate, we've found the single transition point and
+ // don't need to check further.
+ if (!ICmpInst::isEquality(Pred))
+ return true;
----------------
fhahn wrote:
I *think* we may be missing test coverage for this early exit.
https://github.com/llvm/llvm-project/pull/143588
More information about the llvm-commits
mailing list