[llvm] [InstCombine] Fold xored one-complemented operand comparisons (PR #69882)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 24 06:48:06 PDT 2023
================
@@ -7127,6 +7127,20 @@ 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(&I, m_c_ICmp(Pred, m_c_Xor(m_Not(m_Value(A)), m_Value(B)),
+ m_Not(m_Value(C)))) &&
+ !I.isEquality())
----------------
elhewaty wrote:
@I didn't write them because they are handled.
Aliv2: https://godbolt.org/z/qaTh55fsa
https://github.com/llvm/llvm-project/pull/69882
More information about the llvm-commits
mailing list