[llvm] [InstCombine] simplify `icmp pred x, ~x` (PR #73990)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 23 09:11:24 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)))) {
----------------
ParkHanbum wrote:
I understand now. there is need to improve our code to use `isKnownNegative` in the future?
https://github.com/llvm/llvm-project/pull/73990
More information about the llvm-commits
mailing list