summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2016-05-17 12:08:55 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2016-05-17 12:08:55 +0000
commitca9a0fe2b926e3821cf4485e7bd9b59407b474f2 (patch)
tree02eee702f827611dc5c76659442fb7c5ffc1cd0b /llvm/lib/Transforms/InstCombine
parent6c1d74a094ddb477bc17aacc2ef37532104eb8d5 (diff)
downloadbcm5719-llvm-ca9a0fe2b926e3821cf4485e7bd9b59407b474f2.tar.gz
bcm5719-llvm-ca9a0fe2b926e3821cf4485e7bd9b59407b474f2.zip
[InstCombine] Don't crash when trying to take an element of a ConstantExpr.
Fixes PR27786. llvm-svn: 269757
Diffstat (limited to 'llvm/lib/Transforms/InstCombine')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 18036356c92..447c43763f3 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -3132,6 +3132,9 @@ static ICmpInst *canonicalizeCmpWithConstant(ICmpInst &I) {
unsigned NumElts = Op1Type->getVectorNumElements();
for (unsigned i = 0; i != NumElts; ++i) {
Constant *Elt = Op1C->getAggregateElement(i);
+ if (!Elt)
+ return nullptr;
+
if (isa<UndefValue>(Elt))
continue;
// Bail out if we can't determine if this constant is min/max or if we
OpenPOWER on IntegriCloud