[llvm] [InstCombine] Fold xored one-complemented operand comparisons (PR #69882)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 22 13:57:06 PDT 2023
================
@@ -7127,6 +7144,18 @@ Instruction *InstCombinerImpl::visitICmpInst(ICmpInst &I) {
return new ICmpInst(I.getInversePredicate(), Builder.CreateAnd(A, B),
Op1);
+ // Transform (~A ^ B) s< ~A --> (A ^ B) s> A,
+ // (~A ^ B) s> ~A --> (A ^ B) s< A,
+ // (~A ^ B) s<= ~A --> (A ^ B) s>= A,
+ // (~A ^ B) s>= ~A --> (A ^ B) s<= A,
+ // (~A ^ B) u< ~A --> (A ^ B) u< A,
+ // (~A ^ B) u> ~A --> (A ^ B) u< A,
+ // (~A ^ B) u<= ~A --> (A ^ B) u>= A,
+ // and (~A ^ B) u>= ~A --> (A ^ B) <= A
+ if (match(Op0, m_Xor(m_Not(m_Value(A)), m_Value(B))) &&
+ match(Op1, m_Not(m_Value(A))) && !I.isEquality())
----------------
elhewaty wrote:
the `~A ^ B pred ~C` is already handled.
https://github.com/llvm/llvm-project/pull/69882
More information about the llvm-commits
mailing list