diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2016-12-02 03:20:58 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2016-12-02 03:20:58 +0000 |
commit | bc0705240e0f57f16919382b3b75263df9a9f2a5 (patch) | |
tree | 1ff0e7415c4d6295cb4baa6ea63b4b38469ff123 /llvm/lib/IR/ConstantFold.cpp | |
parent | c3be225895ec2373753b2a23f5aced6bad872d81 (diff) | |
download | bcm5719-llvm-bc0705240e0f57f16919382b3b75263df9a9f2a5.tar.gz bcm5719-llvm-bc0705240e0f57f16919382b3b75263df9a9f2a5.zip |
IR: Move NumElements field from {Array,Vector}Type to SequentialType.
Now that PointerType is no longer a SequentialType, all SequentialTypes
have an associated number of elements, so we can move that information to
the base class, allowing for a number of simplifications.
Differential Revision: https://reviews.llvm.org/D27122
llvm-svn: 288464
Diffstat (limited to 'llvm/lib/IR/ConstantFold.cpp')
-rw-r--r-- | llvm/lib/IR/ConstantFold.cpp | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp index 6360b4503a4..e14ea78c27f 100644 --- a/llvm/lib/IR/ConstantFold.cpp +++ b/llvm/lib/IR/ConstantFold.cpp @@ -891,10 +891,8 @@ Constant *llvm::ConstantFoldInsertValueInstruction(Constant *Agg, unsigned NumElts; if (StructType *ST = dyn_cast<StructType>(Agg->getType())) NumElts = ST->getNumElements(); - else if (ArrayType *AT = dyn_cast<ArrayType>(Agg->getType())) - NumElts = AT->getNumElements(); else - NumElts = Agg->getType()->getVectorNumElements(); + NumElts = cast<SequentialType>(Agg->getType())->getNumElements(); SmallVector<Constant*, 32> Result; for (unsigned i = 0; i != NumElts; ++i) { @@ -2210,10 +2208,7 @@ Constant *llvm::ConstantFoldGetElementPtr(Type *PointeeTy, Constant *C, Unknown = true; continue; } - if (isIndexInRangeOfArrayType(isa<ArrayType>(STy) - ? cast<ArrayType>(STy)->getNumElements() - : cast<VectorType>(STy)->getNumElements(), - CI)) + if (isIndexInRangeOfArrayType(STy->getNumElements(), CI)) // It's in range, skip to the next index. continue; if (isa<StructType>(Prev)) { |