[llvm] [SCEV] Consolidate code for proving wrap flags of controlling finite IVs (PR #101404)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 1 03:20:47 PDT 2024
================
@@ -12935,21 +12928,10 @@ ScalarEvolution::howManyLessThans(const SCEV *LHS, const SCEV *RHS,
Stride = getUMaxExpr(Stride, getOne(Stride->getType()));
}
}
- } else if (!Stride->isOne() && !NoWrap) {
- auto isUBOnWrap = [&]() {
- // From no-self-wrap, we need to then prove no-(un)signed-wrap. This
- // follows trivially from the fact that every (un)signed-wrapped, but
- // not self-wrapped value must be LT than the last value before
- // (un)signed wrap. Since we know that last value didn't exit, nor
- // will any smaller one.
- return canAssumeNoSelfWrap(IV);
- };
-
+ } else if (!NoWrap) {
// Avoid proven overflow cases: this will ensure that the backedge taken
- // count will not generate any unsigned overflow. Relaxed no-overflow
- // conditions exploit NoWrapFlags, allowing to optimize in presence of
- // undefined behaviors like the case of C language.
- if (canIVOverflowOnLT(RHS, Stride, IsSigned) && !isUBOnWrap())
+ // count will not generate any unsigned overflow. .
----------------
nikic wrote:
```suggestion
// count will not generate any unsigned overflow.
```
https://github.com/llvm/llvm-project/pull/101404
More information about the llvm-commits
mailing list