[llvm] [DAGCombiner] Add combine avg from shifts (PR #113909)

Sam Parker via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 28 07:00:17 PDT 2024


================
@@ -11393,6 +11413,56 @@ static SDValue combineMinNumMaxNumImpl(const SDLoc &DL, EVT VT, SDValue LHS,
   }
 }
 
+SDValue DAGCombiner::combineAVG(SDNode *N) {
+  const auto Opcode = N->getOpcode();
+
+  // Convert (sr[al] (add n[su]w x, y)) -> (avgfloor[su] x, y)
+  if (Opcode != ISD::SRA && Opcode != ISD::SRL)
+    return SDValue();
+
+  unsigned FloorISD = 0;
+  auto VT = N->getValueType(0);
+  unsigned Shift = N->getOpcode();
----------------
sparker-arm wrote:

`Opcode` has already been assigned this.

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


More information about the llvm-commits mailing list