From e60cb7d1be4aac850c69486cf69f0c5fe250e3af Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Thu, 23 May 2019 21:49:47 +0000 Subject: [InstSimplify] insertelement V, undef, ? --> V This was part of InstCombine, but it's better placed in InstSimplify. InstCombine also had an unreachable but weaker fold for insertelement with undef index, so that is deleted. llvm-svn: 361559 --- llvm/lib/Analysis/InstructionSimplify.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'llvm/lib/Analysis/InstructionSimplify.cpp') diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index b71841a1607..6e421dcaa73 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -4011,6 +4011,11 @@ Value *llvm::SimplifyInsertElementInst(Value *Vec, Value *Val, Value *Idx, if (isa(Idx)) return UndefValue::get(Vec->getType()); + // Inserting an undef scalar? Assume it is the same value as the existing + // vector element. + if (isa(Val)) + return Vec; + return nullptr; } -- cgit v1.2.3