[llvm] [DAGCombiner] Add combine avg from shifts (PR #113909)
David Green via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 29 02:36:50 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:
Do we need to check that the shift is by 1?
https://github.com/llvm/llvm-project/pull/113909
More information about the llvm-commits
mailing list