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

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 20 03:04:47 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()) {
----------------
nikic wrote:

Maybe I missed it somewhere, but it looks like while the implementation was generalized to isNegative(), all the tests still use -1 only? It would be good to change some of them to a different negative value.

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


More information about the llvm-commits mailing list