[llvm] [InstCombine] Fold (sub (xor X, (sext C)), (sext C)) => (select C (neg X), X) (PR #79417)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 25 21:56:52 PST 2024
================
@@ -2448,6 +2448,16 @@ Instruction *InstCombinerImpl::visitSub(BinaryOperator &I) {
}
}
+ {
+ // (sub (xor X, (sext C)), (sext C)) => (select C (neg X), X)
+ Value *C0, *C1, *X;
+ if (match(Op0, m_Xor(m_Value(X), m_SExt(m_Value(C0)))) &&
----------------
dtcxzyw wrote:
Please also handle the commuted version: `(sub (sext C), (xor X, (sext C))) -> select C, X, (neg X)`.
Missing one-use checks?
https://github.com/llvm/llvm-project/pull/79417
More information about the llvm-commits
mailing list