Use the right method to get the # elements in a CDS.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148897 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp
index 7ee716f..43b3af2 100644
--- a/lib/Analysis/ConstantFolding.cpp
+++ b/lib/Analysis/ConstantFolding.cpp
@@ -351,7 +351,7 @@
     uint64_t EltSize = CDS->getElementByteSize();
     uint64_t Index = ByteOffset / EltSize;    
     uint64_t Offset = ByteOffset - Index * EltSize;
-    for (; Index != CDS->getType()->getNumElements(); ++Index) {
+    for (unsigned e = CDS->getNumElements(); Index != e; ++Index) {
       if (!ReadDataFromGlobal(CDS->getElementAsConstant(Index), Offset, CurPtr,
                               BytesLeft, TD))
         return false;
@@ -1042,7 +1042,7 @@
         return 0;
       C = CA->getOperand(IdxVal);
     } else if (ConstantDataSequential *CDS=dyn_cast<ConstantDataSequential>(C)){
-      if (IdxVal >= CDS->getType()->getNumElements())
+      if (IdxVal >= CDS->getNumElements())
         return 0;
       C = CDS->getElementAsConstant(IdxVal);
     } else if (ConstantVector *CV = dyn_cast<ConstantVector>(C)) {
diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp
index 753ec18..ca55fcb 100644
--- a/lib/Analysis/ValueTracking.cpp
+++ b/lib/Analysis/ValueTracking.cpp
@@ -105,7 +105,7 @@
     // each element.
     KnownZero.setAllBits(); KnownOne.setAllBits();
     APInt Elt(KnownZero.getBitWidth(), 0);
-    for (unsigned i = 0, e = CDS->getType()->getNumElements(); i != e; ++i) {
+    for (unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
       Elt = CDS->getElementAsInteger(i);
       KnownZero &= ~Elt;
       KnownOne &= Elt;