Constfold insertelement to undef when index is out-of-bounds
authorPawel Bylica <chfast@gmail.com>
Mon, 27 Apr 2015 09:30:49 +0000 (09:30 +0000)
committerPawel Bylica <chfast@gmail.com>
Mon, 27 Apr 2015 09:30:49 +0000 (09:30 +0000)
commit59764b94a7f64e8622d1b6052537fd14763f55cc
treeda4d26d4bb06143a285d7a42ac6f67d6a5f7dbbf
parent6df35e7844c84d5cf67c6bda6df221629f6aab63
Constfold insertelement to undef when index is out-of-bounds

Summary:
This patch adds constant folding of insertelement instruction to undef value when index operand is constant and is not less than vector size or is undef.

InstCombine does not support this case, but I'm happy to add it there also if this change is accepted.

Test Plan: Unittests and regression tests for ConstProp pass.

Reviewers: majnemer

Reviewed By: majnemer

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D9287

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235854 91177308-0d34-0410-b5e6-96231b3b80d8
lib/IR/ConstantFold.cpp
test/Transforms/ConstProp/InsertElement.ll
unittests/IR/ConstantsTest.cpp