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

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 6 08:32:21 PDT 2024


================
@@ -4605,6 +4605,27 @@ static Instruction *foldICmpXorXX(ICmpInst &I, const SimplifyQuery &Q,
       isKnownNonZero(A, Q.DL, /*Depth=*/0, Q.AC, Q.CxtI, Q.DT))
     return new ICmpInst(PredOut, Op0, Op1);
 
+  // These transform works when C is negative.
+  // X s< X^C, X s<= X^C, X u> X^C, X u>= X^C  --> X s< 0
+  // X s> X^C, X s>= X^C, X u< X^C, X u<= X^C  --> X s>= 0
----------------
nikic wrote:

It may make sense to change C -> A here, to match the name of the variable in the code.

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


More information about the llvm-commits mailing list