[llvm] [InstCombine] simplify `icmp pred x, ~x` (PR #73990)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 8 01:49:26 PST 2023


================
@@ -7035,6 +7035,51 @@ Instruction *InstCombinerImpl::visitICmpInst(ICmpInst &I) {
       return new ICmpInst(I.getSwappedPredicate(Pred), Builder.CreateXor(X, Y),
                           Z);
 
+    // Transform X s<  ~X  -->   X s<  0
+    //           X s>  ~X  -->   X s>  -1
+    //           X s>= ~X  -->   X s>  -1
+    //           X s<= ~X  -->   X s<  0
+    //           X u<  ~X  -->   X s>  -1
----------------
nikic wrote:

I've updated the description with https://alive2.llvm.org/ce/z/KTCpjP, which contains the proofs that match what the implementation does.

https://github.com/llvm/llvm-project/pull/73990


More information about the llvm-commits mailing list