aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/ValueTracking.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2012-01-25 06:48:06 +0000
committerChris Lattner <sabre@nondot.org>2012-01-25 06:48:06 +0000
commita1f00f4d488eb5daff52faaf99c62ee652fd3b85 (patch)
tree0eae19e36e8626cb494b38c88596988b44299120 /lib/Analysis/ValueTracking.cpp
parent969ba287cd2be9b2d6843db6fa5337585f84283b (diff)
use Constant::getAggregateElement to simplify a bunch of code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148934 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ValueTracking.cpp')
-rw-r--r--lib/Analysis/ValueTracking.cpp19
1 files changed, 6 insertions, 13 deletions
diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp
index ca55fcbc6e..21008a1467 100644
--- a/lib/Analysis/ValueTracking.cpp
+++ b/lib/Analysis/ValueTracking.cpp
@@ -1493,19 +1493,12 @@ Value *llvm::FindInsertedValue(Value *V, ArrayRef<unsigned> idx_range,
"Not looking at a struct or array?");
assert(ExtractValueInst::getIndexedType(V->getType(), idx_range) &&
"Invalid indices for type?");
- CompositeType *PTy = cast<CompositeType>(V->getType());
-
- if (isa<UndefValue>(V))
- return UndefValue::get(ExtractValueInst::getIndexedType(PTy, idx_range));
- if (isa<ConstantAggregateZero>(V))
- return Constant::getNullValue(ExtractValueInst::getIndexedType(PTy,
- idx_range));
- if (isa<ConstantArray>(V) || isa<ConstantStruct>(V))
- // Recursively process this constant
- return FindInsertedValue(cast<Constant>(V)->getOperand(idx_range[0]),
- idx_range.slice(1), InsertBefore);
- if (ConstantDataSequential *CDS = dyn_cast<ConstantDataSequential>(V))
- return CDS->getElementAsConstant(idx_range[0]);
+
+ if (Constant *C = dyn_cast<Constant>(V)) {
+ C = C->getAggregateElement(idx_range[0]);
+ if (C == 0) return 0;
+ return FindInsertedValue(C, idx_range.slice(1), InsertBefore);
+ }
if (InsertValueInst *I = dyn_cast<InsertValueInst>(V)) {
// Loop the indices for the insertvalue instruction in parallel with the