@@ -5228,7 +5228,7 @@ SDValue DAGCombiner::visitAVG(SDNode *N) {
5228
5228
return N0;
5229
5229
5230
5230
// fold (avgfloor x, 0) -> x >> 1
5231
- SDValue X;
5231
+ SDValue X, Y ;
5232
5232
if (sd_match(N, m_c_BinOp(ISD::AVGFLOORS, m_Value(X), m_Zero())))
5233
5233
return DAG.getNode(ISD::SRA, DL, VT, X,
5234
5234
DAG.getShiftAmountConstant(1, VT, DL));
@@ -5237,20 +5237,18 @@ SDValue DAGCombiner::visitAVG(SDNode *N) {
5237
5237
DAG.getShiftAmountConstant(1, VT, DL));
5238
5238
5239
5239
// fold avgu(zext(x), zext(y)) -> zext(avgu(x, y))
5240
- SDValue A;
5241
- SDValue B;
5242
5240
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 );
5247
5245
return DAG.getNode(ISD::ZERO_EXTEND, DL, VT, AvgFloorU);
5248
5246
}
5249
5247
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 );
5254
5252
return DAG.getNode(ISD::ZERO_EXTEND, DL, VT, AvgCeilU);
5255
5253
}
5256
5254
0 commit comments