[llvm] [DAG] fold avgu(zext(x), zext(y)) -> zext(avgu(x, y)) (PR #95134)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 11 08:46:05 PDT 2024
================
@@ -5236,6 +5236,21 @@ SDValue DAGCombiner::visitAVG(SDNode *N) {
return DAG.getNode(ISD::SRL, DL, VT, X,
DAG.getShiftAmountConstant(1, VT, DL));
+ // fold avgu(zext(x), zext(y)) -> zext(avgu(x, y))
+ SDValue A;
+ SDValue B;
+ if (hasOperation(ISD::AVGFLOORU, VT) &&
+ sd_match(N, m_c_BinOp(ISD::AVGFLOORU, m_ZExt(m_Value(A)),
+ m_ZExt(m_Value(B))))) {
+ SDValue AvgFloorU = DAG.getNode(ISD::AVGFLOORU, DL, A.getValueType(), A, B);
----------------
jayfoad wrote:
Don't you also need to check that A and B are both being extended _from_ the same size?
https://github.com/llvm/llvm-project/pull/95134
More information about the llvm-commits
mailing list