[llvm] [InstCombine] simplify `x (comp) ~x` (PR #73990)

via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 1 01:04:16 PST 2023


================
@@ -7035,6 +7035,63 @@ 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>  ~X
+    //           X s<= ~X  -->   X s<  ~X
----------------
ParkHanbum wrote:

I have a question. 

if result of code I added are different with result of PASS, which result is better to comment?

example. in my code, `X u<= ~X` transform to `X u>  -128` but PASS final result is `X s> -1`


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


More information about the llvm-commits mailing list