[llvm] [DAG] Recognise AVGFLOOR (((A >> 1) + (B >> 1)) + (A & B & 1)) patterns (PR #169644)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 2 10:17:39 PST 2025
================
@@ -3154,19 +3154,31 @@ SDValue DAGCombiner::visitADDLike(SDNode *N) {
}
// Attempt to form avgfloor(A, B) from (A & B) + ((A ^ B) >> 1)
+// Attempt to form avgfloor(A, B) from ((A >> 1) + (B >> 1)) + (A & B & 1)
SDValue DAGCombiner::foldAddToAvg(SDNode *N, const SDLoc &DL) {
SDValue N0 = N->getOperand(0);
EVT VT = N0.getValueType();
SDValue A, B;
+ // FIXME: m_ReassociatableAdd can't handle m_Value/m_Deferred mixing.
----------------
RKSimon wrote:
Not sure - hence I punted this to #169645 - I can find a workaround if necessary as a followup, but I'd much prefer to handle this completely with m_Reassociatable matchers if possible.
https://github.com/llvm/llvm-project/pull/169644
More information about the llvm-commits
mailing list