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

via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 2 20:36:47 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
----------------
ParkHanbum wrote:

Sure. Please refer to the following link. I also left this link in the commit message. If you need anything else, please let me know.

test proof : https://alive2.llvm.org/ce/z/oXwqbX
logic proof : https://alive2.llvm.org/ce/z/gFVje4



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


More information about the llvm-commits mailing list