Skip to content

Commit b1484f7

Browse files
committed
[DAG] visitAVG - use X/Y SDValue args to match the fold comment. NFC.
1 parent 27ac46e commit b1484f7

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5228,7 +5228,7 @@ SDValue DAGCombiner::visitAVG(SDNode *N) {
52285228
return N0;
52295229

52305230
// fold (avgfloor x, 0) -> x >> 1
5231-
SDValue X;
5231+
SDValue X, Y;
52325232
if (sd_match(N, m_c_BinOp(ISD::AVGFLOORS, m_Value(X), m_Zero())))
52335233
return DAG.getNode(ISD::SRA, DL, VT, X,
52345234
DAG.getShiftAmountConstant(1, VT, DL));
@@ -5237,20 +5237,18 @@ SDValue DAGCombiner::visitAVG(SDNode *N) {
52375237
DAG.getShiftAmountConstant(1, VT, DL));
52385238

52395239
// fold avgu(zext(x), zext(y)) -> zext(avgu(x, y))
5240-
SDValue A;
5241-
SDValue B;
52425240
if (sd_match(
5243-
N, m_BinOp(ISD::AVGFLOORU, m_ZExt(m_Value(A)), m_ZExt(m_Value(B)))) &&
5244-
A.getValueType() == B.getValueType() &&
5245-
hasOperation(ISD::AVGFLOORU, A.getValueType())) {
5246-
SDValue AvgFloorU = DAG.getNode(ISD::AVGFLOORU, DL, A.getValueType(), A, B);
5241+
N, m_BinOp(ISD::AVGFLOORU, m_ZExt(m_Value(X)), m_ZExt(m_Value(Y)))) &&
5242+
X.getValueType() == Y.getValueType() &&
5243+
hasOperation(ISD::AVGFLOORU, X.getValueType())) {
5244+
SDValue AvgFloorU = DAG.getNode(ISD::AVGFLOORU, DL, X.getValueType(), X, Y);
52475245
return DAG.getNode(ISD::ZERO_EXTEND, DL, VT, AvgFloorU);
52485246
}
52495247
if (sd_match(
5250-
N, m_BinOp(ISD::AVGCEILU, m_ZExt(m_Value(A)), m_ZExt(m_Value(B)))) &&
5251-
A.getValueType() == B.getValueType() &&
5252-
hasOperation(ISD::AVGCEILU, A.getValueType())) {
5253-
SDValue AvgCeilU = DAG.getNode(ISD::AVGCEILU, DL, A.getValueType(), A, B);
5248+
N, m_BinOp(ISD::AVGCEILU, m_ZExt(m_Value(X)), m_ZExt(m_Value(Y)))) &&
5249+
X.getValueType() == Y.getValueType() &&
5250+
hasOperation(ISD::AVGCEILU, X.getValueType())) {
5251+
SDValue AvgCeilU = DAG.getNode(ISD::AVGCEILU, DL, X.getValueType(), X, Y);
52545252
return DAG.getNode(ISD::ZERO_EXTEND, DL, VT, AvgCeilU);
52555253
}
52565254

0 commit comments

Comments
 (0)