[llvm] [ScalarEvolution] howManyLessThans infer stride isPositive from guard (PR #214014)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 26 11:56:35 PDT 2026
================
@@ -13465,6 +13465,14 @@ ScalarEvolution::howManyLessThans(const SCEV *LHS, const SCEV *RHS,
const SCEV *Stride = IV->getStepRecurrence(*this);
bool PositiveStride = isKnownPositive(Stride);
+ // A dominating guard may prove the stride positive.
+ if (!PositiveStride) {
+ const SCEV *GuardedStride = applyLoopGuards(Stride, L);
+ if (isKnownPositive(GuardedStride)) {
+ Stride = GuardedStride;
----------------
nikic wrote:
Is continuing with the guarded stride (rather than the original stride) here beneficial? I'd expect that using the guarded stride results in a more complex BECount.
https://github.com/llvm/llvm-project/pull/214014
More information about the llvm-commits
mailing list