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

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 26 15:25:53 PDT 2016


efriedma 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
----------------
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.


Repository:
  rL LLVM

https://reviews.llvm.org/D25913





More information about the llvm-commits mailing list