[PATCH] D45439: [IRCE] Use NUW flag for indvar
Max Kazantsev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 9 22:09:38 PDT 2018
mkazantsev added inline comments.
================
Comment at: lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp:936
// not wrap. This restriction can potentially be lifted in the future.
-
- if (!HasNoSignedWrap(AR))
+ if (!HasNoSignedWrap(AR) && !AR->hasNoUnsignedWrap())
return false;
----------------
mkazantsev wrote:
> mkazantsev wrote:
> > This does not feel right. What if the indvar goes from `SINT_MAX - 10` to `SINT_MIN + 10` and, thus, has signed wrap? In this case it might have `nuw`, but if we deal with signed predicates, we might miscompile.
> >
> > I think the correct approach would be to identify whether the latch predicate is signed or unsigned, and if it is unsigned, then we may check `nuw` instead of `nsw`.
> BTW, why it is `&&` and not `||`? I think you were extending the scope of optimization, not narrowing it.
Ah, forget it, it's `!`... Scratch my 2nd comment on that.
https://reviews.llvm.org/D45439
More information about the llvm-commits
mailing list