[PATCH] D103844: [SCEV] Cache wrap facts for positive IVs w/LT exits
Philip Reames via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 9 14:08:33 PDT 2021
reames added inline comments.
================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:11518
+ // We have proven that IV can not overflow, remember that fact.
+ setNoWrapFlags(const_cast<SCEVAddRecExpr *>(IV), WrapType);
}
----------------
nikic wrote:
> If we consider the `canIVOverflowOnLT()` case, the only thin this guarantees is that `RHS + Stride - 1` does not overflow, it doesn't make a direct statement about the addrec.
>
> If the loop exits before reaching this exit (for simplicity: abnormal exit on first iteration), then I don't think we can really make any statement about the nowrap behavior of the addrec.
Right, but we know that the result of the expression being considered must reach a conditional branch, and that conditional branch must dominate the latch. Given that, we know that if this condition did overflow, then the iteration of the loop would be UB unless we exit from some other exit before this one. In either case, that seems to give an upper bound on the trip count which does imply that AddRec can't overflow in a well defined loop doesn't it?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D103844/new/
https://reviews.llvm.org/D103844
More information about the llvm-commits
mailing list