[PATCH] D45439: [IRCE] Use NUW flag for indvar

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 15 18:13:52 PDT 2018


mkazantsev added inline comments.


================
Comment at: lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp:894
+  auto HasNoWrap = [&](const SCEVAddRecExpr *AR) {
+    if (AR->hasNoSelfWrap())
       return true;
----------------
mkazantsev wrote:
> This is incorrect. If counter value goes from `-1` to `(SINT_MAX + 1)` (both included), it has both signed and unsigned wrap and has no self-wrap.
Just to clarify the example: we start with `i = -1` and go up with step of `1` and exit the loop when `i = SINT_MAX + 1`. In this case when we pass from `-1` to `0` we are making an unsigned wrap and when we pass from `SINT_MAX` to `SINT_MAX + 1` we are making a signed wrap. There is no self-wrap because this variable will never reach `-1` again.


https://reviews.llvm.org/D45439





More information about the llvm-commits mailing list