[PATCH] D24700: [InstCombine] optimize unsigned icmp of inc/dec like signed

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 19 11:49:38 PDT 2016


sanjoy added a subscriber: sanjoy.
sanjoy requested changes to this revision.
sanjoy added a reviewer: sanjoy.
sanjoy added a comment.
This revision now requires changes to proceed.

I think we can be more aggressive here:  the only non-poison value for `(X +nuw -1)` is `-1`, and we should be exploiting that.


================
Comment at: lib/Transforms/InstCombine/InstCombineCompares.cpp:2832
@@ +2831,3 @@
+
+  // icmp uge (X + -1), Y -> icmp ugt X, Y
+  if (A && NoOp0WrapProblem && Pred == CmpInst::ICMP_UGE &&
----------------
This looks wrong --  if `X` and `Y` are both `0` then `uge (X +nuw -1) Y` is `uge -1 0` == `true` but `ugt X Y` is `ugt 0 0` = `false`.  Same for some of the cases below.


https://reviews.llvm.org/D24700





More information about the llvm-commits mailing list