[llvm] 3fca9d7 - [X86] combineMul - use DAG::getNegative() helper. NFC.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 30 02:43:38 PDT 2024
Author: Simon Pilgrim
Date: 2024-04-30T10:43:14+01:00
New Revision: 3fca9d71447b7d3536e912d73ffd56a351e10bce
URL: https://github.com/llvm/llvm-project/commit/3fca9d71447b7d3536e912d73ffd56a351e10bce
DIFF: https://github.com/llvm/llvm-project/commit/3fca9d71447b7d3536e912d73ffd56a351e10bce.diff
LOG: [X86] combineMul - use DAG::getNegative() helper. NFC.
Added:
Modified:
llvm/lib/Target/X86/X86ISelLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index e9b4b08532c969..f99db7a9c9b175 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -47247,8 +47247,7 @@ static SDValue combineMul(SDNode *N, SelectionDAG &DAG,
NewMul = DAG.getNode(X86ISD::MUL_IMM, DL, VT, N->getOperand(0),
DAG.getConstant(AbsMulAmt, DL, VT));
if (SignMulAmt < 0)
- NewMul =
- DAG.getNode(ISD::SUB, DL, VT, DAG.getConstant(0, DL, VT), NewMul);
+ NewMul = DAG.getNegative(NewMul, DL, VT);
return NewMul;
}
@@ -47295,8 +47294,7 @@ static SDValue combineMul(SDNode *N, SelectionDAG &DAG,
// Negate the result.
if (SignMulAmt < 0)
- NewMul =
- DAG.getNode(ISD::SUB, DL, VT, DAG.getConstant(0, DL, VT), NewMul);
+ NewMul = DAG.getNegative(NewMul, DL, VT);
} else if (!Subtarget.slowLEA())
NewMul = combineMulSpecial(C->getZExtValue(), N, DAG, VT, DL);
}
@@ -47312,10 +47310,8 @@ static SDValue combineMul(SDNode *N, SelectionDAG &DAG,
ISD::ADD, DL, VT, N->getOperand(0),
DAG.getNode(ISD::SHL, DL, VT, N->getOperand(0),
DAG.getConstant(Log2_64(AbsMulAmt - 1), DL, ShiftVT)));
- // To negate, subtract the number from zero
if (SignMulAmt < 0)
- NewMul =
- DAG.getNode(ISD::SUB, DL, VT, DAG.getConstant(0, DL, VT), NewMul);
+ NewMul = DAG.getNegative(NewMul, DL, VT);
} else if (isPowerOf2_64(AbsMulAmt + 1)) {
// (mul x, 2^N - 1) => (sub (shl x, N), x)
NewMul =
More information about the llvm-commits
mailing list