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

David Green via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 30 09:46:11 PDT 2024


================
@@ -11393,6 +11422,53 @@ static SDValue combineMinNumMaxNumImpl(const SDLoc &DL, EVT VT, SDValue LHS,
   }
 }
 
+SDValue DAGCombiner::foldShiftToAvg(SDNode *N) {
+  const unsigned Opcode = N->getOpcode();
+
+  // Convert (sr[al] (add n[su]w x, y)) -> (avgfloor[su] x, y)
+  if (Opcode != ISD::SRA && Opcode != ISD::SRL)
----------------
davemgreen wrote:

Ah I see - I had missed that in the matcher and expected it to be up here.

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


More information about the llvm-commits mailing list