[llvm] [WIP] Fold (bitwiseop X, (add (not Y), Z)) -> (bitwiseop X, (not (sub Y, Z))). (PR #141476)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu May 29 02:45:40 PDT 2025


================
@@ -11609,6 +11625,35 @@ SDValue DAGCombiner::foldShiftToAvg(SDNode *N) {
   return DAG.getNode(FloorISD, SDLoc(N), N->getValueType(0), {A, B});
 }
 
+SDValue DAGCombiner::foldBitwiseOpWithNeg(SDNode *N) {
+  if (!TLI.hasAndNot(SDValue(N, 0)))
+    return SDValue();
+
+  unsigned Opc = N->getOpcode();
+  if (Opc != ISD::AND && Opc != ISD::OR && Opc != ISD::XOR)
+    return SDValue();
----------------
RKSimon wrote:

you can drop these and replace `m_c_BinOp(Opc, X, Y)` with `m_BitwiseLogic(X,Y)`

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


More information about the llvm-commits mailing list