llvm-project/llvm/lib/Transforms
Alexey Bataev fee9078dcd [InstCombine] Fix for PR29124: reduce insertelements to shufflevector
If inserting more than one constant into a vector:

define <4 x float> @foo(<4 x float> %x) {
  %ins1 = insertelement <4 x float> %x, float 1.0, i32 1
  %ins2 = insertelement <4 x float> %ins1, float 2.0, i32 2
  ret <4 x float> %ins2
}

InstCombine could reduce that to a shufflevector:

define <4 x float> @goo(<4 x float> %x) {
 %shuf = shufflevector <4 x float> %x, <4 x float> <float undef, float 1.0, float 2.0, float undef>, <4 x i32><i32 0, i32 5, i32 6, i32 3>
 ret <4 x float> %shuf
}
Also, InstCombine tries to convert shuffle instruction to single insertelement, if one of the vectors is a constant vector and only a single element from this constant should be used in shuffle, i.e.
shufflevector <4 x float> %v, <4 x float> <float undef, float 1.0, float
undef, float undef>, <4 x i32> <i32 0, i32 5, i32 undef, i32 undef> ->
insertelement <4 x float> %v, float 1.0, 1

Differential Revision: https://reviews.llvm.org/D24182

llvm-svn: 282237
2016-09-23 09:14:08 +00:00
..
Coroutines [Coroutines] Part13: Handle single edge PHINodes across suspends 2016-09-09 05:39:00 +00:00
Hello Add auto-exporting of symbols from tools so that plugins work on Windows 2016-05-26 11:16:43 +00:00
IPO Change the basic block weight calculation algorithm to use max instead of voting. 2016-09-21 16:26:51 +00:00
InstCombine [InstCombine] Fix for PR29124: reduce insertelements to shufflevector 2016-09-23 09:14:08 +00:00
Instrumentation [compiler-rt] fix typo in option description [NFC] 2016-09-22 14:57:24 +00:00
ObjCARC Address Pete's review comment and define OrigArg on its own line. 2016-09-13 23:53:43 +00:00
Scalar Revert r282168 "GVN-hoist: fix store past load dependence analysis (PR30216)" 2016-09-22 21:20:53 +00:00
Utils Reapplying r281895 (and follow-up r281964) after fixing pr30468. 2016-09-22 14:13:25 +00:00
Vectorize [LV] Don't emit unused scalars for uniform instructions 2016-09-21 16:50:24 +00:00
CMakeLists.txt [coroutines] Part 3 of N: Adding Boilerplate for Coroutine Passes 2016-07-28 21:04:31 +00:00
LLVMBuild.txt [coroutines] Part 3 of N: Adding Boilerplate for Coroutine Passes 2016-07-28 21:04:31 +00:00