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

Sam Parker via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 10 09:03:05 PDT 2018


samparker added inline comments.


================
Comment at: lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp:929
 
-    if (!HasNoSignedWrap(AR))
-      return false;
----------------
samparker wrote:
> samparker wrote:
> > mkazantsev wrote:
> > > mkazantsev wrote:
> > > > Actually I look into it and the old implementation seems suspicious to me. We only check `nsw`, but when we don't have `nuw` and actually do have an unsigned wrap, why don't we have a bug on unsigned latch predicates? Or we do, but not aware about?.. :)
> > > If you look at `HasNoSignedWrap`, it has a bit more complex check than just looking into the immediate flag, it also tries to go through `sext` to find this flag. Can we do the same for `nuw` and `zext` to keep things consistent?
> > Is this case handled on line 915?
> Ok, I'll make some changes. I also need to handle equality differently, because I believe its classed as unsigned which messes up the NoSignedWrap check.
I'm trying to understand test_02 of decrementing_loop. The test looks like it should work, but I can't figure out how the transform is making the decision. If I try to check nuw on unsigned and nsw on signed values, this test stops being transformed because it figures the indvar is NSW but ULT is being used.


https://reviews.llvm.org/D45439





More information about the llvm-commits mailing list