diff options
| author | Igor Laevsky <igmyrj@gmail.com> | 2017-12-07 15:00:52 +0000 |
|---|---|---|
| committer | Igor Laevsky <igmyrj@gmail.com> | 2017-12-07 15:00:52 +0000 |
| commit | 4a4f2e8c67c5fed1b4abacbc307137953d2f00a3 (patch) | |
| tree | f9d4ffa77691b6313360aca17013a4772ba0a644 /llvm/lib | |
| parent | ff5212091a39188d02aa435b66adb5c86e4b4a72 (diff) | |
| download | bcm5719-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.cpp | 4 |
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); |

