summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-05-24 17:34:30 +0000
committerChris Lattner <sabre@nondot.org>2006-05-24 17:34:30 +0000
commita643d528bd40b7799f2886e367effd625ae45623 (patch)
treee4202f3cd6359d073819db98dabc696aaad45e53 /llvm/lib/Transforms
parentfb5fc7606305a9e720e900420e9f8adea5767578 (diff)
downloadbcm5719-llvm-a643d528bd40b7799f2886e367effd625ae45623.tar.gz
bcm5719-llvm-a643d528bd40b7799f2886e367effd625ae45623.zip
Patch for a new instcombine xform, patch contributed by Nick Lewycky!
This implements Transforms/InstCombine/2006-05-10-InvalidIndexUndef.ll llvm-svn: 28450
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index a848e7461eb..3998923dd1a 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -273,7 +273,8 @@ Constant *llvm::ConstantFoldLoadThroughGEPConstantExpr(Constant *C,
}
} else if (ConstantInt *CI = dyn_cast<ConstantInt>(I.getOperand())) {
if (const ArrayType *ATy = dyn_cast<ArrayType>(*I)) {
- if ((uint64_t)CI->getRawValue() >= ATy->getNumElements()) return 0;
+ if ((uint64_t)CI->getRawValue() >= ATy->getNumElements())
+ C = UndefValue::get(ATy->getElementType());
if (ConstantArray *CA = dyn_cast<ConstantArray>(C))
C = CA->getOperand((unsigned)CI->getRawValue());
else if (isa<ConstantAggregateZero>(C))
@@ -283,7 +284,8 @@ Constant *llvm::ConstantFoldLoadThroughGEPConstantExpr(Constant *C,
else
return 0;
} else if (const PackedType *PTy = dyn_cast<PackedType>(*I)) {
- if ((uint64_t)CI->getRawValue() >= PTy->getNumElements()) return 0;
+ if ((uint64_t)CI->getRawValue() >= PTy->getNumElements())
+ C = UndefValue::get(PTy->getElementType());
if (ConstantPacked *CP = dyn_cast<ConstantPacked>(C))
C = CP->getOperand((unsigned)CI->getRawValue());
else if (isa<ConstantAggregateZero>(C))
OpenPOWER on IntegriCloud