[PATCH] D40390: [InstCombine] Don't crash on out of bounds index in the insertelement
Igor Laevsky via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 30 07:56:36 PST 2017
igor-laevsky updated this revision to Diff 124941.
igor-laevsky added a comment.
Thanks, this way is a lot better. Updated the diff.
https://reviews.llvm.org/D40390
Files:
lib/Transforms/InstCombine/InstCombineVectorOps.cpp
test/Transforms/InstCombine/out-of-bounds-indexes.ll
Index: test/Transforms/InstCombine/out-of-bounds-indexes.ll
===================================================================
--- test/Transforms/InstCombine/out-of-bounds-indexes.ll
+++ test/Transforms/InstCombine/out-of-bounds-indexes.ll
@@ -11,3 +11,13 @@
}
declare void @llvm.assume(i1)
+
+define void @test(<4 x double> %a, <4 x double> %b) {
+entry:
+ %sub.i = fsub ninf <4 x double> %a, %b
+ %I = insertelement <4 x double> %sub.i, double 0x7FEFFFFFFFFFFFFF, i64 4294967296
+ %B = lshr i8 127, 0
+ store i8 %B, i8* undef
+ store <4 x double> %I, <4 x double>* undef
+ ret void
+}
Index: lib/Transforms/InstCombine/InstCombineVectorOps.cpp
===================================================================
--- lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -782,6 +782,10 @@
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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40390.124941.patch
Type: text/x-patch
Size: 1252 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171130/14ed90c4/attachment.bin>
More information about the llvm-commits
mailing list