[llvm] [LV] Use SCEV to check if IV overflow check is known (PR #115705)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 11 04:07:01 PST 2024
================
@@ -2491,17 +2491,19 @@ void InnerLoopVectorizer::emitIterationCountCheck(BasicBlock *Bypass) {
Value *LHS = Builder.CreateSub(MaxUIntTripCount, Count);
Value *Step = CreateStep();
-#ifndef NDEBUG
ScalarEvolution &SE = *PSE.getSE();
const SCEV *TC2OverflowSCEV = SE.applyLoopGuards(SE.getSCEV(LHS), OrigLoop);
- assert(
- !isIndvarOverflowCheckKnownFalse(Cost, VF * UF) &&
- !SE.isKnownPredicate(CmpInst::getInversePredicate(ICmpInst::ICMP_ULT),
- TC2OverflowSCEV, SE.getSCEV(Step)) &&
- "unexpectedly proved overflow check to be known");
-#endif
- // Don't execute the vector loop if (UMax - n) < (VF * UF).
- CheckMinIters = Builder.CreateICmp(ICmpInst::ICMP_ULT, LHS, Step);
+ const SCEV *StepSCEV = SE.getSCEV(Step);
+
+ // Check if (UMax - n) < (VF * UF).
+ if (SE.isKnownPredicate(ICmpInst::ICMP_ULT, TC2OverflowSCEV, StepSCEV)) {
----------------
david-arm wrote:
The patch to add the NDEBUG code landed only recently - https://github.com/llvm/llvm-project/pull/111310 by @fhahn. It looks like this assert was added for a reason - is it possible that `isIndvarOverflowCheckKnownFalse` is returning the incorrect answer for the EVL case?
https://github.com/llvm/llvm-project/pull/115705
More information about the llvm-commits
mailing list