Skip to content

Commit d839e76

Browse files
committed
[TargetLowering] Inline the only caller of one of the forceExpandWideMUL functions. NFC
This caller does not need the libcall portion so it can directly call forceExpandMultiply.
1 parent 194c74e commit d839e76

File tree

3 files changed

+5
-67
lines changed

3 files changed

+5
-67
lines changed

llvm/include/llvm/CodeGen/TargetLowering.h

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5512,20 +5512,10 @@ class TargetLowering : public TargetLoweringBase {
55125512
SDValue HiLHS = SDValue(),
55135513
SDValue HiRHS = SDValue()) const;
55145514

5515-
/// forceExpandWideMUL - Unconditionally expand a MUL into either a libcall or
5516-
/// brute force via a wide multiplication. The expansion works by
5517-
/// attempting to do a multiplication on a wider type twice the size of the
5518-
/// original operands. LL and LH represent the lower and upper halves of the
5519-
/// first operand. RL and RH represent the lower and upper halves of the
5520-
/// second operand. The upper and lower halves of the result are stored in Lo
5521-
/// and Hi.
5522-
void forceExpandWideMUL(SelectionDAG &DAG, const SDLoc &dl, bool Signed,
5523-
EVT WideVT, const SDValue LL, const SDValue LH,
5524-
const SDValue RL, const SDValue RH, SDValue &Lo,
5525-
SDValue &Hi) const;
5526-
5527-
/// Same as above, but creates the upper halves of each operand by
5528-
/// sign/zero-extending the operands.
5515+
/// Calculate full product of LHS and RHS either via a libcall or through
5516+
/// brute force expansion of the multiplication. The expansion works by
5517+
/// splitting the 2 inputs into 4 pieces that we can multiply and add together
5518+
/// without needing MULH or MUL_LOHI.
55295519
void forceExpandWideMUL(SelectionDAG &DAG, const SDLoc &dl, bool Signed,
55305520
const SDValue LHS, const SDValue RHS, SDValue &Lo,
55315521
SDValue &Hi) const;

llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4296,8 +4296,7 @@ void DAGTypeLegalizer::ExpandIntRes_MUL(SDNode *N,
42964296
if (LC == RTLIB::UNKNOWN_LIBCALL || !TLI.getLibcallName(LC)) {
42974297
// Perform a wide multiplication where the wide type is the original VT and
42984298
// the 4 parts are the split arguments.
4299-
TLI.forceExpandWideMUL(DAG, dl, /*Signed=*/true, VT, LL, LH, RL, RH, Lo,
4300-
Hi);
4299+
TLI.forceExpandMultiply(DAG, dl, /*Signed=*/false, Lo, Hi, LL, RL, LH, RH);
43014300
return;
43024301
}
43034302

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -10915,57 +10915,6 @@ void TargetLowering::forceExpandMultiply(SelectionDAG &DAG, const SDLoc &dl,
1091510915
}
1091610916
}
1091710917

10918-
void TargetLowering::forceExpandWideMUL(SelectionDAG &DAG, const SDLoc &dl,
10919-
bool Signed, EVT WideVT,
10920-
const SDValue LL, const SDValue LH,
10921-
const SDValue RL, const SDValue RH,
10922-
SDValue &Lo, SDValue &Hi) const {
10923-
// We can fall back to a libcall with an illegal type for the MUL if we
10924-
// have a libcall big enough.
10925-
// Also, we can fall back to a division in some cases, but that's a big
10926-
// performance hit in the general case.
10927-
RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
10928-
if (WideVT == MVT::i16)
10929-
LC = RTLIB::MUL_I16;
10930-
else if (WideVT == MVT::i32)
10931-
LC = RTLIB::MUL_I32;
10932-
else if (WideVT == MVT::i64)
10933-
LC = RTLIB::MUL_I64;
10934-
else if (WideVT == MVT::i128)
10935-
LC = RTLIB::MUL_I128;
10936-
10937-
if (LC == RTLIB::UNKNOWN_LIBCALL || !getLibcallName(LC)) {
10938-
forceExpandMultiply(DAG, dl, /*Signed=*/false, Lo, Hi, LL, RL, LH, RH);
10939-
} else {
10940-
// Attempt a libcall.
10941-
SDValue Ret;
10942-
TargetLowering::MakeLibCallOptions CallOptions;
10943-
CallOptions.setIsSigned(Signed);
10944-
CallOptions.setIsPostTypeLegalization(true);
10945-
if (shouldSplitFunctionArgumentsAsLittleEndian(DAG.getDataLayout())) {
10946-
// Halves of WideVT are packed into registers in different order
10947-
// depending on platform endianness. This is usually handled by
10948-
// the C calling convention, but we can't defer to it in
10949-
// the legalizer.
10950-
SDValue Args[] = {LL, LH, RL, RH};
10951-
Ret = makeLibCall(DAG, LC, WideVT, Args, CallOptions, dl).first;
10952-
} else {
10953-
SDValue Args[] = {LH, LL, RH, RL};
10954-
Ret = makeLibCall(DAG, LC, WideVT, Args, CallOptions, dl).first;
10955-
}
10956-
assert(Ret.getOpcode() == ISD::MERGE_VALUES &&
10957-
"Ret value is a collection of constituent nodes holding result.");
10958-
if (DAG.getDataLayout().isLittleEndian()) {
10959-
// Same as above.
10960-
Lo = Ret.getOperand(0);
10961-
Hi = Ret.getOperand(1);
10962-
} else {
10963-
Lo = Ret.getOperand(1);
10964-
Hi = Ret.getOperand(0);
10965-
}
10966-
}
10967-
}
10968-
1096910918
void TargetLowering::forceExpandWideMUL(SelectionDAG &DAG, const SDLoc &dl,
1097010919
bool Signed, const SDValue LHS,
1097110920
const SDValue RHS, SDValue &Lo,

0 commit comments

Comments
 (0)