@@ -3981,8 +3981,7 @@ SDValue DAGCombiner::visitMUL(SDNode *N) {
39813981
39823982 // fold (mul x, -1) -> 0-x
39833983 if (N1IsConst && ConstValue1.isAllOnes())
3984- return DAG.getNode(ISD::SUB, DL, VT,
3985- DAG.getConstant(0, DL, VT), N0);
3984+ return DAG.getNegative(N0, DL, VT);
39863985
39873986 // fold (mul x, (1 << c)) -> x << c
39883987 if (isConstantOrConstantVector(N1, /*NoOpaques*/ true) &&
@@ -4049,7 +4048,7 @@ SDValue DAGCombiner::visitMUL(SDNode *N) {
40494048 DAG.getConstant(TZeros, DL, VT)))
40504049 : DAG.getNode(MathOp, DL, VT, Shl, N0);
40514050 if (ConstValue1.isNegative())
4052- R = DAG.getNode(ISD::SUB , DL, VT, DAG.getConstant(0, DL, VT), R );
4051+ R = DAG.getNegative(R , DL, VT);
40534052 return R;
40544053 }
40554054 }
@@ -4303,7 +4302,7 @@ SDValue DAGCombiner::visitSDIV(SDNode *N) {
43034302 // fold (sdiv X, -1) -> 0-X
43044303 ConstantSDNode *N1C = isConstOrConstSplat(N1);
43054304 if (N1C && N1C->isAllOnes())
4306- return DAG.getNode(ISD::SUB , DL, VT, DAG.getConstant(0, DL, VT), N0 );
4305+ return DAG.getNegative(N0 , DL, VT);
43074306
43084307 // fold (sdiv X, MIN_SIGNED) -> select(X == MIN_SIGNED, 1, 0)
43094308 if (N1C && N1C->getAPIntValue().isMinSignedValue())
@@ -8682,8 +8681,7 @@ SDValue DAGCombiner::visitXOR(SDNode *N) {
86828681 // fold (not (add X, -1)) -> (neg X)
86838682 if (isAllOnesConstant(N1) && N0.getOpcode() == ISD::ADD &&
86848683 isAllOnesOrAllOnesSplat(N0.getOperand(1))) {
8685- return DAG.getNode(ISD::SUB, DL, VT, DAG.getConstant(0, DL, VT),
8686- N0.getOperand(0));
8684+ return DAG.getNegative(N0.getOperand(0), DL, VT);
86878685 }
86888686
86898687 // fold (xor (and x, y), y) -> (and (not x), y)
@@ -11305,8 +11303,7 @@ SDValue DAGCombiner::visitVSELECT(SDNode *N) {
1130511303 if (SatCC == ISD::SETUGT && Other.getOpcode() == ISD::ADD &&
1130611304 ISD::matchBinaryPredicate(OpRHS, CondRHS, MatchUSUBSAT,
1130711305 /*AllowUndefs*/ true)) {
11308- OpRHS = DAG.getNode(ISD::SUB, DL, VT,
11309- DAG.getConstant(0, DL, VT), OpRHS);
11306+ OpRHS = DAG.getNegative(OpRHS, DL, VT);
1131011307 return DAG.getNode(ISD::USUBSAT, DL, VT, OpLHS, OpRHS);
1131111308 }
1131211309
@@ -12394,7 +12391,7 @@ SDValue DAGCombiner::visitSIGN_EXTEND(SDNode *N) {
1239412391 N0.getOperand(1).getOpcode() == ISD::ZERO_EXTEND &&
1239512392 TLI.isOperationLegalOrCustom(ISD::SUB, VT)) {
1239612393 SDValue Zext = DAG.getZExtOrTrunc(N0.getOperand(1).getOperand(0), DL, VT);
12397- return DAG.getNode(ISD::SUB , DL, VT, DAG.getConstant(0, DL, VT), Zext );
12394+ return DAG.getNegative(Zext , DL, VT);
1239812395 }
1239912396 // Eliminate this sign extend by doing a decrement in the destination type:
1240012397 // sext i32 ((zext i8 X to i32) + (-1)) to i64 --> (zext i8 X to i64) + (-1)
0 commit comments