Skip to content

Commit c046b68

Browse files
committed
Pull out repeated value types. NFCI.
llvm-svn: 344355
1 parent b926fd7 commit c046b68

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2708,10 +2708,11 @@ SDValue SelectionDAGLegalize::ExpandBSWAP(SDValue Op, const SDLoc &dl) {
27082708
/// Expand the specified bitcount instruction into operations.
27092709
SDValue SelectionDAGLegalize::ExpandBitCount(unsigned Opc, SDValue Op,
27102710
const SDLoc &dl) {
2711+
EVT VT = Op.getValueType();
2712+
27112713
switch (Opc) {
27122714
default: llvm_unreachable("Cannot expand this yet!");
27132715
case ISD::CTPOP: {
2714-
EVT VT = Op.getValueType();
27152716
EVT ShVT = TLI.getShiftAmountTy(VT, DAG.getDataLayout());
27162717
unsigned Len = VT.getSizeInBits();
27172718

@@ -2758,9 +2759,8 @@ SDValue SelectionDAGLegalize::ExpandBitCount(unsigned Opc, SDValue Op,
27582759
}
27592760
case ISD::CTLZ_ZERO_UNDEF:
27602761
// This trivially expands to CTLZ.
2761-
return DAG.getNode(ISD::CTLZ, dl, Op.getValueType(), Op);
2762+
return DAG.getNode(ISD::CTLZ, dl, VT, Op);
27622763
case ISD::CTLZ: {
2763-
EVT VT = Op.getValueType();
27642764
unsigned Len = VT.getScalarSizeInBits();
27652765

27662766
if (TLI.isOperationLegalOrCustom(ISD::CTLZ_ZERO_UNDEF, VT)) {
@@ -2792,9 +2792,8 @@ SDValue SelectionDAGLegalize::ExpandBitCount(unsigned Opc, SDValue Op,
27922792
}
27932793
case ISD::CTTZ_ZERO_UNDEF:
27942794
// This trivially expands to CTTZ.
2795-
return DAG.getNode(ISD::CTTZ, dl, Op.getValueType(), Op);
2795+
return DAG.getNode(ISD::CTTZ, dl, VT, Op);
27962796
case ISD::CTTZ: {
2797-
EVT VT = Op.getValueType();
27982797
unsigned Len = VT.getSizeInBits();
27992798

28002799
if (TLI.isOperationLegalOrCustom(ISD::CTTZ_ZERO_UNDEF, VT)) {
@@ -2818,7 +2817,7 @@ SDValue SelectionDAGLegalize::ExpandBitCount(unsigned Opc, SDValue Op,
28182817
if (!TLI.isOperationLegalOrCustom(ISD::CTPOP, VT) &&
28192818
TLI.isOperationLegalOrCustom(ISD::CTLZ, VT))
28202819
return DAG.getNode(ISD::SUB, dl, VT,
2821-
DAG.getConstant(VT.getSizeInBits(), dl, VT),
2820+
DAG.getConstant(Len, dl, VT),
28222821
DAG.getNode(ISD::CTLZ, dl, VT, Tmp3));
28232822
return DAG.getNode(ISD::CTPOP, dl, VT, Tmp3);
28242823
}

0 commit comments

Comments
 (0)