@@ -58113,13 +58113,14 @@ static SDValue combineAdd(SDNode *N, SelectionDAG &DAG,
58113
58113
}
58114
58114
}
58115
58115
58116
- // If vectors of i1 are legal, turn (add (zext (vXi1 X)), Y) into
58117
- // (sub Y, (sext (vXi1 X))).
58118
- // FIXME: We have the (sub Y, (zext (vXi1 X))) -> (add (sext (vXi1 X)), Y) in
58119
- // generic DAG combine without a legal type check, but adding this there
58120
- // caused regressions.
58121
58116
if (VT.isVector()) {
58122
58117
SDValue X, Y;
58118
+
58119
+ // If vectors of i1 are legal, turn (add (zext (vXi1 X)), Y) into
58120
+ // (sub Y, (sext (vXi1 X))).
58121
+ // FIXME: We have the (sub Y, (zext (vXi1 X))) -> (add (sext (vXi1 X)), Y)
58122
+ // in generic DAG combine without a legal type check, but adding this there
58123
+ // caused regressions.
58123
58124
EVT BoolVT = EVT::getVectorVT(*DAG.getContext(), MVT::i1,
58124
58125
VT.getVectorElementCount());
58125
58126
if (DAG.getTargetLoweringInfo().isTypeLegal(BoolVT) &&
@@ -58128,6 +58129,15 @@ static SDValue combineAdd(SDNode *N, SelectionDAG &DAG,
58128
58129
SDValue SExt = DAG.getNode(ISD::SIGN_EXTEND, DL, VT, X);
58129
58130
return DAG.getNode(ISD::SUB, DL, VT, Y, SExt);
58130
58131
}
58132
+
58133
+ // Fold (add X, (srl Y, 7)) -> (sub X, (ashr Y, 7)) to undo instcombine
58134
+ // canonicalisation as we don't have good vXi8 shifts.
58135
+ if (VT.getScalarType() == MVT::i8 &&
58136
+ sd_match(N, m_Add(m_Value(X), m_Srl(m_Value(Y), m_SpecificInt(7))))) {
58137
+ SDValue AShr = DAG.getNode(ISD::SRA, DL, VT, Y,
58138
+ DAG.getShiftAmountConstant(7, VT, DL));
58139
+ return DAG.getNode(ISD::SUB, DL, VT, X, AShr);
58140
+ }
58131
58141
}
58132
58142
58133
58143
// Peephole for 512-bit VPDPBSSD on non-VLX targets.
0 commit comments