[llvm] [InstSimplify] Simplify select if it combinated `and/or/xor` (PR #73362)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 6 08:59:52 PST 2023
================
@@ -4434,6 +4434,61 @@ Value *llvm::simplifyWithOpReplaced(Value *V, Value *Op, Value *RepOp,
RecursionLimit);
}
+/// Try simplifying the selection command when condition, trueValue, and
+/// falseValue are combinations of special bitwise operators.
+static Value *simplifySelectBitTestSpec(Value *CmpLHS, Value *CmpRHS,
+ Value *TrueVal, Value *FalseVal) {
+ Value *X, *Y;
+ // (X & Y) == 0 ? X | Y : X ^ Y --> X ^ Y
+ // (X & Y) == 0 ? X ^ Y : X | Y --> X | Y
+ // (X & Y) != 0 ? X | Y : X ^ Y --> X | Y
+ // (X & Y) != 0 ? X ^ Y : X | Y --> X ^ Y
+ if (match(CmpLHS, m_c_And(m_Value(X), m_Value(Y))) &&
----------------
goldsteinn wrote:
Don't need commutative and here (In general you don't need it on a commutative binop unless there is an `m_Specific` or `m_Deferred`). Likewise below.
https://github.com/llvm/llvm-project/pull/73362
More information about the llvm-commits
mailing list