[llvm] change contents of ScalarEvolution from private to protected (PR #83052)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 6 00:51:38 PST 2024
================
@@ -12733,38 +12983,50 @@ ScalarEvolution::howManyLessThans(const SCEV *LHS, const SCEV *RHS,
if (auto *ZExt = dyn_cast<SCEVZeroExtendExpr>(LHS)) {
const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(ZExt->getOperand());
if (AR && AR->getLoop() == L && AR->isAffine()) {
- auto canProveNUW = [&]() {
- // We can use the comparison to infer no-wrap flags only if it fully
- // controls the loop exit.
- if (!ControlsOnlyExit)
- return false;
-
- if (!isLoopInvariant(RHS, L))
- return false;
-
- if (!isKnownNonZero(AR->getStepRecurrence(*this)))
- // We need the sequence defined by AR to strictly increase in the
- // unsigned integer domain for the logic below to hold.
- return false;
-
- const unsigned InnerBitWidth = getTypeSizeInBits(AR->getType());
- const unsigned OuterBitWidth = getTypeSizeInBits(RHS->getType());
- // If RHS <=u Limit, then there must exist a value V in the sequence
- // defined by AR (e.g. {Start,+,Step}) such that V >u RHS, and
- // V <=u UINT_MAX. Thus, we must exit the loop before unsigned
- // overflow occurs. This limit also implies that a signed comparison
- // (in the wide bitwidth) is equivalent to an unsigned comparison as
- // the high bits on both sides must be zero.
- APInt StrideMax = getUnsignedRangeMax(AR->getStepRecurrence(*this));
- APInt Limit = APInt::getMaxValue(InnerBitWidth) - (StrideMax - 1);
- Limit = Limit.zext(OuterBitWidth);
- return getUnsignedRangeMax(applyLoopGuards(RHS, L)).ule(Limit);
- };
- auto Flags = AR->getNoWrapFlags();
- if (!hasFlags(Flags, SCEV::FlagNUW) && canProveNUW())
- Flags = setFlags(Flags, SCEV::FlagNUW);
+ if (!AssumeLoopExists) {
----------------
nikic wrote:
Here also, sounds like this just wasn't backported to enyzme's fork?
https://github.com/llvm/llvm-project/pull/83052
More information about the llvm-commits
mailing list