[PATCH] D104140: [SCEV] Allow negative steps for LT exit count computation
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 16 12:35:47 PDT 2021
efriedma added inline comments.
================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:11559
APInt One(BitWidth, 1, IsSigned);
StrideForMaxBECount = APIntOps::smax(One, StrideForMaxBECount);
----------------
Is the unconditional use of "smax" here going to cause issues?
================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:11570
APInt MaxEnd = IsSigned ? APIntOps::smin(getSignedRangeMax(End), Limit)
: APIntOps::umin(getUnsignedRangeMax(End), Limit);
----------------
Instead of computing `min(End, Limit) - Start`, should we be using `max(End, Start) - Start` like we do elsewhere?
================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:11634
+ // Precondition b) implies that if the stride is zero, this is a single
+ // trip loop. The backedge taken count formula reduces to zero in this case.
//
----------------
This is inductive logic, right? If the first iteration doesn't the loop, the following iterations also can't exit the loop.
I think this logic requires that RHS is invariant? Not that we would compute BECount anyway in that case, but I think we might underestimate MaxBECount.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D104140/new/
https://reviews.llvm.org/D104140
More information about the llvm-commits
mailing list