[llvm] [InstCombine] simplify `icmp pred x, ~x` (PR #73990)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 22 10:17:30 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:
not x and neg_x, but `x` and `x ^ neg_c` (although the eq/ne ones work for any `x` and `x ^ NonZero`.
https://github.com/llvm/llvm-project/pull/73990
More information about the llvm-commits
mailing list