[PATCH] D87832: [IndVars] Remove monotonic checks with unknown exit count
Max Kazantsev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 28 23:34:46 PDT 2020
mkazantsev added inline comments.
================
Comment at: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:2375-2388
+ // The predicate must be monotonic.
+ switch (Pred) {
+ default:
+ return false;
+ case ICmpInst::ICMP_SLT:
+ case ICmpInst::ICMP_ULT:
+ case ICmpInst::ICMP_SGT:
----------------
mkazantsev wrote:
> reames wrote:
> > lebedev.ri wrote:
> > > It might be good to hoist that into some ICmp method,
> > > this is at least the second such code block.
> > It really looks like at least part of this logic can be replaced with SE->isMonotonicPredicate(LHSS, Pred, IncreasingOut). In particular, I think that covers all your tricky overflow logic and does so more generally.
> >
> > If I'm right about that, you can also generalize this. Consider:
> > - If is monotonic, and proven start == proven end (without caring which direction proved), the condition is invariant for the iterations executed.
> >
> > This is starting to look a lot like it might belong in isLoopInvariantPredicate. It seems to be a generalization of the logic there.
> It does not. It requires proved nsw/nuw flags. We are OK if the last iteration actually does overflow, but in this case we exit the loop before our check.
`isRelational` seems to be what we need.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87832/new/
https://reviews.llvm.org/D87832
More information about the llvm-commits
mailing list