[llvm] [InstCombine] simplify `icmp pred x, ~x` (PR #73990)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 10 14:39:00 PDT 2024
================
@@ -4540,14 +4540,45 @@ static Instruction *foldICmpXorXX(ICmpInst &I, const SimplifyQuery &Q,
if (!match(Op0, m_c_Xor(m_Specific(Op1), m_Value(A))))
return nullptr;
+ CmpInst::Predicate StrictPred = ICmpInst::getStrictPredicate(Pred);
+ // Transform
+ // X s< ~X, X s<= ~X, X u> ~X, X u>= ~X
+ // --> X s< 0
+ // X s> ~X, X s>= ~X, X u< ~X, X u<= ~X
+ // --> X s> -1
+ // X == ~X --> false
+ // X != ~X --> true
+ if (match(Op0, m_Not(m_Specific(Op1)))) {
----------------
goldsteinn wrote:
These all work for any `xor x, neg_C`:
https://alive2.llvm.org/ce/z/6LR8Nn
https://github.com/llvm/llvm-project/pull/73990
More information about the llvm-commits
mailing list