[PATCH] D24480: [InstCombine] remove fold: zext(bool) + C -> bool ? C + 1 : C

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 12 17:24:19 PDT 2016


efriedma added a comment.

The general direction seems fine.


================
Comment at: lib/Transforms/InstCombine/InstCombineAddSub.cpp:1070
@@ -1069,5 +1069,3 @@
 
-    // zext(bool) + C -> bool ? C + 1 : C
-    if (ZExtInst *ZI = dyn_cast<ZExtInst>(LHS))
-      if (ZI->getSrcTy()->isIntegerTy(1))
-        return SelectInst::Create(ZI->getOperand(0), AddOne(CI), CI);
+    // add (zext (icmp Pred X, Y)), -1 --> sext (icmp Pred' X, Y)
+    Instruction *ZextOp;
----------------
I guess we should prefer sext(cmp) over add(zext(cmp), -1), but we prefer add(zext(cmp), N) over add(sext(cmp), N-1) for any other N?  That works, but you might want to explain that here.


https://reviews.llvm.org/D24480





More information about the llvm-commits mailing list