summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/InstructionSimplify.cpp
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2017-12-26 11:42:39 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2017-12-26 11:42:39 +0000
commit79c2c2f08c8513be679b2ff8ad3a53b2db3343d9 (patch)
tree46e1f1937503c165afa30cebd6ac7aa64ff0735a /llvm/lib/Analysis/InstructionSimplify.cpp
parentc67d6b2da0a651a48408ca03ee2edc1bc9a3c29a (diff)
downloadbcm5719-llvm-79c2c2f08c8513be679b2ff8ad3a53b2db3343d9.tar.gz
bcm5719-llvm-79c2c2f08c8513be679b2ff8ad3a53b2db3343d9.zip
[InstSimplify] Check for in range extraction index before calling APInt::getZExtValue()
Reduced from oss-fuzz #4768 test case llvm-svn: 321454
Diffstat (limited to 'llvm/lib/Analysis/InstructionSimplify.cpp')
-rw-r--r--llvm/lib/Analysis/InstructionSimplify.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 3ce1281743c..fac6a917dc9 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -3897,8 +3897,9 @@ static Value *SimplifyExtractElementInst(Value *Vec, Value *Idx, const SimplifyQ
// If extracting a specified index from the vector, see if we can recursively
// find a previously computed scalar that was inserted into the vector.
if (auto *IdxC = dyn_cast<ConstantInt>(Idx))
- if (Value *Elt = findScalarElement(Vec, IdxC->getZExtValue()))
- return Elt;
+ if (IdxC->getValue().ule(Vec->getType()->getVectorNumElements()))
+ if (Value *Elt = findScalarElement(Vec, IdxC->getZExtValue()))
+ return Elt;
// An undef extract index can be arbitrarily chosen to be an out-of-range
// index value, which would result in the instruction being undef.
OpenPOWER on IntegriCloud