[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:42 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();
+
+  SDValue N1 = N->getOperand(1);
+  EVT VT = N1.getValueType();
+  SDLoc DL(N);
----------------
RKSimon wrote:

pass in `const SDLoc &DL` and remove this

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


More information about the llvm-commits mailing list