Skip to content

Commit 9ad9d15

Browse files
committed
[X86] Convert ShrinkMode to scoped enum class. NFCI.
1 parent 1abb2c1 commit 9ad9d15

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37861,7 +37861,7 @@ static SDValue combineCMov(SDNode *N, SelectionDAG &DAG,
3786137861
}
3786237862

3786337863
/// Different mul shrinking modes.
37864-
enum ShrinkMode { MULS8, MULU8, MULS16, MULU16 };
37864+
enum class ShrinkMode { MULS8, MULU8, MULS16, MULU16 };
3786537865

3786637866
static bool canReduceVMulWidth(SDNode *N, SelectionDAG &DAG, ShrinkMode &Mode) {
3786737867
EVT VT = N->getOperand(0).getValueType();
@@ -37882,16 +37882,16 @@ static bool canReduceVMulWidth(SDNode *N, SelectionDAG &DAG, ShrinkMode &Mode) {
3788237882
unsigned MinSignBits = std::min(SignBits[0], SignBits[1]);
3788337883
// When ranges are from -128 ~ 127, use MULS8 mode.
3788437884
if (MinSignBits >= 25)
37885-
Mode = MULS8;
37885+
Mode = ShrinkMode::MULS8;
3788637886
// When ranges are from 0 ~ 255, use MULU8 mode.
3788737887
else if (AllPositive && MinSignBits >= 24)
37888-
Mode = MULU8;
37888+
Mode = ShrinkMode::MULU8;
3788937889
// When ranges are from -32768 ~ 32767, use MULS16 mode.
3789037890
else if (MinSignBits >= 17)
37891-
Mode = MULS16;
37891+
Mode = ShrinkMode::MULS16;
3789237892
// When ranges are from 0 ~ 65535, use MULU16 mode.
3789337893
else if (AllPositive && MinSignBits >= 16)
37894-
Mode = MULU16;
37894+
Mode = ShrinkMode::MULU16;
3789537895
else
3789637896
return false;
3789737897
return true;
@@ -37961,15 +37961,17 @@ static SDValue reduceVMULWidth(SDNode *N, SelectionDAG &DAG,
3796137961
// Generate the lower part of mul: pmullw. For MULU8/MULS8, only the
3796237962
// lower part is needed.
3796337963
SDValue MulLo = DAG.getNode(ISD::MUL, DL, ReducedVT, NewN0, NewN1);
37964-
if (Mode == MULU8 || Mode == MULS8)
37965-
return DAG.getNode((Mode == MULU8) ? ISD::ZERO_EXTEND : ISD::SIGN_EXTEND,
37964+
if (Mode == ShrinkMode::MULU8 || Mode == ShrinkMode::MULS8)
37965+
return DAG.getNode((Mode == ShrinkMode::MULU8) ? ISD::ZERO_EXTEND
37966+
: ISD::SIGN_EXTEND,
3796637967
DL, VT, MulLo);
3796737968

3796837969
MVT ResVT = MVT::getVectorVT(MVT::i32, NumElts / 2);
3796937970
// Generate the higher part of mul: pmulhw/pmulhuw. For MULU16/MULS16,
3797037971
// the higher part is also needed.
37971-
SDValue MulHi = DAG.getNode(Mode == MULS16 ? ISD::MULHS : ISD::MULHU, DL,
37972-
ReducedVT, NewN0, NewN1);
37972+
SDValue MulHi =
37973+
DAG.getNode(Mode == ShrinkMode::MULS16 ? ISD::MULHS : ISD::MULHU, DL,
37974+
ReducedVT, NewN0, NewN1);
3797337975

3797437976
// Repack the lower part and higher part result of mul into a wider
3797537977
// result.
@@ -43818,7 +43820,8 @@ static SDValue combineLoopMAddPattern(SDNode *N, SelectionDAG &DAG,
4381843820
auto UsePMADDWD = [&](SDValue Op) {
4381943821
ShrinkMode Mode;
4382043822
return Op.getOpcode() == ISD::MUL &&
43821-
canReduceVMulWidth(Op.getNode(), DAG, Mode) && Mode != MULU16 &&
43823+
canReduceVMulWidth(Op.getNode(), DAG, Mode) &&
43824+
Mode != ShrinkMode::MULU16 &&
4382243825
(!Subtarget.hasSSE41() ||
4382343826
(Op->isOnlyUserOf(Op.getOperand(0).getNode()) &&
4382443827
Op->isOnlyUserOf(Op.getOperand(1).getNode())));
@@ -44023,7 +44026,8 @@ static SDValue matchPMADDWD(SelectionDAG &DAG, SDValue Op0, SDValue Op1,
4402344026

4402444027
// Check if the Mul source can be safely shrunk.
4402544028
ShrinkMode Mode;
44026-
if (!canReduceVMulWidth(Mul.getNode(), DAG, Mode) || Mode == MULU16)
44029+
if (!canReduceVMulWidth(Mul.getNode(), DAG, Mode) ||
44030+
Mode == ShrinkMode::MULU16)
4402744031
return SDValue();
4402844032

4402944033
auto PMADDBuilder = [](SelectionDAG &DAG, const SDLoc &DL,

0 commit comments

Comments
 (0)