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(ScalarOp) || isa(IdxOp)) replaceInstUsesWith(IE, VecOp); 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 +}