[llvm] [InstSimplify] Simplify select if it combinated `and/or/xor` (PR #73362)

via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 26 09:47:14 PST 2023


================
@@ -4425,6 +4425,48 @@ 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 *TrueVal, Value *FalseVal,
+                                        Value *X, Value *Y,
+                                        bool TrueWhenUnset) {
+  // (X & Y) == 0 ? X | Y : X ^ Y   --> X ^ Y
+  // (X & Y) == 0 ? X ^ Y : X | Y   --> X | Y
+  // (X & Y) == 1 ? X | Y : X ^ Y   --> X | Y
+  // (X & Y) == 1 ? X ^ Y : X | Y   --> X ^ Y
----------------
goldsteinn wrote:

in general `== 1` is really `!= 0`.

https://github.com/llvm/llvm-project/pull/73362


More information about the llvm-commits mailing list