summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/ConstantFold.cpp
diff options
context:
space:
mode:
authorDaniel Berlin <dberlin@dberlin.org>2017-05-08 17:37:29 +0000
committerDaniel Berlin <dberlin@dberlin.org>2017-05-08 17:37:29 +0000
commit74ffa5c62fd248c3009c615808da8737a45301ab (patch)
treee89455f8f51822ac68325e427982bcdba49af7f5 /llvm/lib/IR/ConstantFold.cpp
parent0fd1b6c0dce83124e7578e54727ec1058a1882da (diff)
downloadbcm5719-llvm-74ffa5c62fd248c3009c615808da8737a45301ab.tar.gz
bcm5719-llvm-74ffa5c62fd248c3009c615808da8737a45301ab.zip
ConstantFold: Fold getelementptr (i32, i32* null, i64 undef) to null.
Transforms/IndVarSimplify/2011-10-27-lftrnull will fail if this regresses. Transforms/GVN/PRE/2011-06-01-NonLocalMemdepMiscompile.ll has been changed to still test what it was trying to test. llvm-svn: 302446
Diffstat (limited to 'llvm/lib/IR/ConstantFold.cpp')
-rw-r--r--llvm/lib/IR/ConstantFold.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index 80b117015ed..c185933254c 100644
--- a/llvm/lib/IR/ConstantFold.cpp
+++ b/llvm/lib/IR/ConstantFold.cpp
@@ -2054,7 +2054,8 @@ Constant *llvm::ConstantFoldGetElementPtr(Type *PointeeTy, Constant *C,
if (C->isNullValue()) {
bool isNull = true;
for (unsigned i = 0, e = Idxs.size(); i != e; ++i)
- if (!cast<Constant>(Idxs[i])->isNullValue()) {
+ if (!isa<UndefValue>(Idxs[i]) &&
+ !cast<Constant>(Idxs[i])->isNullValue()) {
isNull = false;
break;
}
OpenPOWER on IntegriCloud