@@ -21060,13 +21060,6 @@ static bool isNegatedInteger(SDValue Op) {
2106021060 return Op.getOpcode() == ISD::SUB && isNullConstant(Op.getOperand(0));
2106121061}
2106221062
21063- static SDValue getNegatedInteger(SDValue Op, SelectionDAG &DAG) {
21064- SDLoc DL(Op);
21065- EVT VT = Op.getValueType();
21066- SDValue Zero = DAG.getConstant(0, DL, VT);
21067- return DAG.getNode(ISD::SUB, DL, VT, Zero, Op);
21068- }
21069-
2107021063// Try to fold
2107121064//
2107221065// (neg (csel X, Y)) -> (csel (neg X), (neg Y))
@@ -21085,16 +21078,17 @@ static SDValue performNegCSelCombine(SDNode *N, SelectionDAG &DAG) {
2108521078 SDValue N0 = CSel.getOperand(0);
2108621079 SDValue N1 = CSel.getOperand(1);
2108721080
21088- // If both of them is not negations, it's not worth the folding as it
21081+ // If neither of them are negations, it's not worth the folding as it
2108921082 // introduces two additional negations while reducing one negation.
2109021083 if (!isNegatedInteger(N0) && !isNegatedInteger(N1))
2109121084 return SDValue();
2109221085
21093- SDValue N0N = getNegatedInteger(N0, DAG);
21094- SDValue N1N = getNegatedInteger(N1, DAG);
21095-
2109621086 SDLoc DL(N);
2109721087 EVT VT = CSel.getValueType();
21088+
21089+ SDValue N0N = DAG.getNegative(N0, DL, VT);
21090+ SDValue N1N = DAG.getNegative(N1, DL, VT);
21091+
2109821092 return DAG.getNode(AArch64ISD::CSEL, DL, VT, N0N, N1N, CSel.getOperand(2),
2109921093 CSel.getOperand(3));
2110021094}
0 commit comments