summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorIgor Laevsky <igmyrj@gmail.com>2017-12-07 15:00:52 +0000
committerIgor Laevsky <igmyrj@gmail.com>2017-12-07 15:00:52 +0000
commit4a4f2e8c67c5fed1b4abacbc307137953d2f00a3 (patch)
treef9d4ffa77691b6313360aca17013a4772ba0a644 /llvm/lib
parentff5212091a39188d02aa435b66adb5c86e4b4a72 (diff)
downloadbcm5719-llvm-4a4f2e8c67c5fed1b4abacbc307137953d2f00a3.tar.gz
bcm5719-llvm-4a4f2e8c67c5fed1b4abacbc307137953d2f00a3.zip
[InstCombine] Don't crash on out of bounds index in the insertelement
Differential Revision: https://reviews.llvm.org/D40390 llvm-svn: 320049
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
index 6c99007475c..65a96b96522 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -781,6 +781,10 @@ Instruction *InstCombiner::visitInsertElementInst(InsertElementInst &IE) {
Value *ScalarOp = IE.getOperand(1);
Value *IdxOp = IE.getOperand(2);
+ if (auto *V = SimplifyInsertElementInst(
+ VecOp, ScalarOp, IdxOp, SQ.getWithInstruction(&IE)))
+ return replaceInstUsesWith(IE, V);
+
// Inserting an undef or into an undefined place, remove this.
if (isa<UndefValue>(ScalarOp) || isa<UndefValue>(IdxOp))
replaceInstUsesWith(IE, VecOp);
OpenPOWER on IntegriCloud