[llvm] r344355 - Pull out repeated value types. NFCI.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 12 08:49:19 PDT 2018


Author: rksimon
Date: Fri Oct 12 08:49:19 2018
New Revision: 344355

URL: http://llvm.org/viewvc/llvm-project?rev=344355&view=rev
Log:
Pull out repeated value types. NFCI.

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=344355&r1=344354&r2=344355&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Fri Oct 12 08:49:19 2018
@@ -2708,10 +2708,11 @@ SDValue SelectionDAGLegalize::ExpandBSWA
 /// Expand the specified bitcount instruction into operations.
 SDValue SelectionDAGLegalize::ExpandBitCount(unsigned Opc, SDValue Op,
                                              const SDLoc &dl) {
+  EVT VT = Op.getValueType();
+
   switch (Opc) {
   default: llvm_unreachable("Cannot expand this yet!");
   case ISD::CTPOP: {
-    EVT VT = Op.getValueType();
     EVT ShVT = TLI.getShiftAmountTy(VT, DAG.getDataLayout());
     unsigned Len = VT.getSizeInBits();
 
@@ -2758,9 +2759,8 @@ SDValue SelectionDAGLegalize::ExpandBitC
   }
   case ISD::CTLZ_ZERO_UNDEF:
     // This trivially expands to CTLZ.
-    return DAG.getNode(ISD::CTLZ, dl, Op.getValueType(), Op);
+    return DAG.getNode(ISD::CTLZ, dl, VT, Op);
   case ISD::CTLZ: {
-    EVT VT = Op.getValueType();
     unsigned Len = VT.getScalarSizeInBits();
 
     if (TLI.isOperationLegalOrCustom(ISD::CTLZ_ZERO_UNDEF, VT)) {
@@ -2792,9 +2792,8 @@ SDValue SelectionDAGLegalize::ExpandBitC
   }
   case ISD::CTTZ_ZERO_UNDEF:
     // This trivially expands to CTTZ.
-    return DAG.getNode(ISD::CTTZ, dl, Op.getValueType(), Op);
+    return DAG.getNode(ISD::CTTZ, dl, VT, Op);
   case ISD::CTTZ: {
-    EVT VT = Op.getValueType();
     unsigned Len = VT.getSizeInBits();
 
     if (TLI.isOperationLegalOrCustom(ISD::CTTZ_ZERO_UNDEF, VT)) {
@@ -2818,7 +2817,7 @@ SDValue SelectionDAGLegalize::ExpandBitC
     if (!TLI.isOperationLegalOrCustom(ISD::CTPOP, VT) &&
         TLI.isOperationLegalOrCustom(ISD::CTLZ, VT))
       return DAG.getNode(ISD::SUB, dl, VT,
-                         DAG.getConstant(VT.getSizeInBits(), dl, VT),
+                         DAG.getConstant(Len, dl, VT),
                          DAG.getNode(ISD::CTLZ, dl, VT, Tmp3));
     return DAG.getNode(ISD::CTPOP, dl, VT, Tmp3);
   }




More information about the llvm-commits mailing list