Remove some dead code and tidy things up now that vectors use ConstantDataVector
instead of always using ConstantVector.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149912 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp
index 48e75a1..6e2a8d4 100644
--- a/lib/Analysis/ConstantFolding.cpp
+++ b/lib/Analysis/ConstantFolding.cpp
@@ -54,37 +54,35 @@
 
   // Handle a vector->integer cast.
   if (IntegerType *IT = dyn_cast<IntegerType>(DestTy)) {
-    // FIXME: Remove ConstantVector support.
-    if ((!isa<ConstantDataVector>(C) && !isa<ConstantVector>(C)) ||
-        // TODO: Handle big endian someday.
-        !TD.isLittleEndian())
+    ConstantDataVector *CDV = dyn_cast<ConstantDataVector>(C);
+    if (CDV == 0)
       return ConstantExpr::getBitCast(C, DestTy);
 
-    unsigned NumSrcElts = C->getType()->getVectorNumElements();
+    unsigned NumSrcElts = CDV->getType()->getNumElements();
+    
+    Type *SrcEltTy = CDV->getType()->getElementType();
     
     // If the vector is a vector of floating point, convert it to vector of int
     // to simplify things.
-    if (C->getType()->getVectorElementType()->isFloatingPointTy()) {
-      unsigned FPWidth =
-        C->getType()->getVectorElementType()->getPrimitiveSizeInBits();
+    if (SrcEltTy->isFloatingPointTy()) {
+      unsigned FPWidth = SrcEltTy->getPrimitiveSizeInBits();
       Type *SrcIVTy =
         VectorType::get(IntegerType::get(C->getContext(), FPWidth), NumSrcElts);
       // Ask VMCore to do the conversion now that #elts line up.
       C = ConstantExpr::getBitCast(C, SrcIVTy);
+      CDV = cast<ConstantDataVector>(C);
     }
     
     // Now that we know that the input value is a vector of integers, just shift
     // and insert them into our result.
-    unsigned BitShift =
-      TD.getTypeAllocSizeInBits(C->getType()->getVectorElementType());
+    unsigned BitShift = TD.getTypeAllocSizeInBits(SrcEltTy);
     APInt Result(IT->getBitWidth(), 0);
     for (unsigned i = 0; i != NumSrcElts; ++i) {
-      // FIXME: Rework when we have ConstantDataVector.
-      ConstantInt *Elt=dyn_cast_or_null<ConstantInt>(C->getAggregateElement(i));
-      if (Elt == 0)  // Elt must be a constant expr or something.
-        return ConstantExpr::getBitCast(C, DestTy);
-      
-      Result |= Elt->getValue().zextOrSelf(IT->getBitWidth()) << i*BitShift;
+      Result <<= BitShift;
+      if (TD.isLittleEndian())
+        Result |= CDV->getElementAsInteger(NumSrcElts-i-1);
+      else
+        Result |= CDV->getElementAsInteger(i);
     }
    
     return ConstantInt::get(IT, Result);
@@ -103,7 +101,6 @@
   }
   
   // If this is a bitcast from constant vector -> vector, fold it.
-  // FIXME: Remove ConstantVector support.
   if (!isa<ConstantDataVector>(C) && !isa<ConstantVector>(C))
     return ConstantExpr::getBitCast(C, DestTy);
   
@@ -350,7 +347,6 @@
     // not reached.
   }
 
-  // FIXME: Remove ConstantVector
   if (isa<ConstantArray>(C) || isa<ConstantVector>(C) ||
       isa<ConstantDataSequential>(C)) {
     Type *EltTy = cast<SequentialType>(C->getType())->getElementType();
diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp
index 1a18247..b5811f2 100644
--- a/lib/Analysis/ValueTracking.cpp
+++ b/lib/Analysis/ValueTracking.cpp
@@ -88,19 +88,8 @@
     return;
   }
   // Handle a constant vector by taking the intersection of the known bits of
-  // each element.
-  // FIXME: Remove.
-  if (ConstantVector *CV = dyn_cast<ConstantVector>(V)) {
-    KnownZero.setAllBits(); KnownOne.setAllBits();
-    for (unsigned i = 0, e = CV->getNumOperands(); i != e; ++i) {
-      APInt KnownZero2(BitWidth, 0), KnownOne2(BitWidth, 0);
-      ComputeMaskedBits(CV->getOperand(i), Mask, KnownZero2, KnownOne2,
-                        TD, Depth);
-      KnownZero &= KnownZero2;
-      KnownOne &= KnownOne2;
-    }
-    return;
-  }
+  // each element.  There is no real need to handle ConstantVector here, because
+  // we don't handle undef in any particularly useful way.
   if (ConstantDataSequential *CDS = dyn_cast<ConstantDataSequential>(V)) {
     // We know that CDS must be a vector of integers. Take the intersection of
     // each element.