Make sure to legalize generated ctpop nodes, convert tabs to spaces
authorChris Lattner <sabre@nondot.org>
Wed, 11 May 2005 18:35:21 +0000 (18:35 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 11 May 2005 18:35:21 +0000 (18:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21868 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

index 19285845de86273ef02a6687169d6ea839e9165f..a19e6119a7c180caed91ee9e774b1556eba52021 100644 (file)
@@ -1134,15 +1134,15 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
       }
       case ISD::CTLZ: {
         /* for now, we do this:
-        x = x | (x >> 1);
-        x = x | (x >> 2);
-        ...
-        x = x | (x >>16);
-        x = x | (x >>32); // for 64-bit input 
-        return popcount(~x);
+           x = x | (x >> 1);
+           x = x | (x >> 2);
+           ...
+           x = x | (x >>16);
+           x = x | (x >>32); // for 64-bit input 
+           return popcount(~x);
         
-       but see also: http://www.hackersdelight.org/HDcode/nlz.cc */
-       MVT::ValueType VT = Tmp1.getValueType();
+           but see also: http://www.hackersdelight.org/HDcode/nlz.cc */
+        MVT::ValueType VT = Tmp1.getValueType();
         MVT::ValueType ShVT = TLI.getShiftAmountTy();
         unsigned len = getSizeInBits(VT);
         for (unsigned i = 0; (1U << i) <= (len / 2); ++i) {
@@ -1151,19 +1151,19 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
                              DAG.getNode(ISD::SRL, VT, Tmp1, Tmp3));
         }
         Tmp3 = DAG.getNode(ISD::XOR, VT, Tmp1, DAG.getConstant(~0ULL, VT));
-       Result = DAG.getNode(ISD::CTPOP, VT, Tmp3);
+        Result = LegalizeOp(DAG.getNode(ISD::CTPOP, VT, Tmp3));
         break;
       }
       case ISD::CTTZ: {
-       // for now, we use: { return popcount(~x & (x - 1)); }
-        // but see also http://www.hackersdelight.org/HDcode/ntz.cc )
-       MVT::ValueType VT = Tmp1.getValueType();
-       Tmp2 = DAG.getConstant(~0ULL, VT);
-       Tmp3 = DAG.getNode(ISD::AND, VT, 
-                             DAG.getNode(ISD::XOR, VT, Tmp1, Tmp2),
-                             DAG.getNode(ISD::SUB, VT, Tmp1,
-                                                  DAG.getConstant(1, VT)));
-       Result = DAG.getNode(ISD::CTPOP, VT, Tmp3);
+        // for now, we use: { return popcount(~x & (x - 1)); }
+        // but see also http://www.hackersdelight.org/HDcode/ntz.cc
+        MVT::ValueType VT = Tmp1.getValueType();
+        Tmp2 = DAG.getConstant(~0ULL, VT);
+        Tmp3 = DAG.getNode(ISD::AND, VT, 
+                           DAG.getNode(ISD::XOR, VT, Tmp1, Tmp2),
+                           DAG.getNode(ISD::SUB, VT, Tmp1,
+                                       DAG.getConstant(1, VT)));
+        Result = LegalizeOp(DAG.getNode(ISD::CTPOP, VT, Tmp3));
         break;
       }
       default: