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

via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 21 10:40:46 PDT 2024


================
@@ -7190,6 +7190,29 @@ Instruction *InstCombinerImpl::visitICmpInst(ICmpInst &I) {
       }
     }
 
+    // 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
+    const APInt *C;
+    if (match(Op0, m_c_Xor(m_Specific(Op1), m_APInt(C))) && C->isNegative()) {
----------------
ParkHanbum wrote:

I'm not against it, but can you tell me why it should be? just for  growing knowledge about llvm.

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


More information about the llvm-commits mailing list