[PATCH] D25913: [InstCombine] Fold nuw left-shifts in `ugt`/`ule` comparisons.

bryant via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 28 07:05:16 PDT 2016


bryant added inline comments.


================
Comment at: lib/Transforms/InstCombine/InstCombineCompares.cpp:1963
+    // (X << S) <=u C = X <=u (C >> S)
+    // (X << S) <u (C + 1) = X <u (C >> S) + 1 if C < - 1
+    // (X << S) <u C = X <u ((C - 1) >> S) + 1 if C > 0
----------------
efriedma wrote:
> bryant wrote:
> > bryant wrote:
> > > efriedma wrote:
> > > > "// (X << S) <u (C + 1) = X <u (C >> S) + 1 if C < - 1"
> > > > 
> > > > This comment is confusing... when exactly is "C < - 1" true?
> > > -1 == all ones. Assuming that addition wraps, `X <=u C` is equivalent to `X <=u (C + 1)` if C + 1 doesn't wrap, or if C is less than all ones.
> > Replace the second `<=u` with `<u`.
> Ah, okay.  You could probably write that in a way that's a little more obvious.
`C < -1u`? `C <u -1`? `C <u ~0u`?


Repository:
  rL LLVM

https://reviews.llvm.org/D25913





More information about the llvm-commits mailing list