1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -disable-peephole -mtriple=i386-apple-darwin -mattr=+sse4.1 -show-mc-encoding | FileCheck %s --check-prefixes=CHECK,X86,SSE,X86-SSE
3 ; RUN: llc < %s -disable-peephole -mtriple=i386-apple-darwin -mattr=+avx -show-mc-encoding | FileCheck %s --check-prefixes=CHECK,X86,AVX,X86-AVX,AVX1,X86-AVX1
4 ; RUN: llc < %s -disable-peephole -mtriple=i386-apple-darwin -mattr=+avx512f,+avx512bw,+avx512dq,+avx512vl -show-mc-encoding | FileCheck %s --check-prefixes=CHECK,X86,AVX,X86-AVX,AVX512,X86-AVX512
5 ; RUN: llc < %s -disable-peephole -mtriple=x86_64-apple-darwin -mattr=+sse4.1 -show-mc-encoding | FileCheck %s --check-prefixes=CHECK,X64,SSE,X64-SSE
6 ; RUN: llc < %s -disable-peephole -mtriple=x86_64-apple-darwin -mattr=+avx -show-mc-encoding | FileCheck %s --check-prefixes=CHECK,X64,AVX,X64-AVX,AVX1,X64-AVX1
7 ; RUN: llc < %s -disable-peephole -mtriple=x86_64-apple-darwin -mattr=+avx512f,+avx512bw,+avx512dq,+avx512vl -show-mc-encoding | FileCheck %s --check-prefixes=CHECK,X64,AVX,X64-AVX,AVX512,X64-AVX512
9 @g16 = external global i16
11 define <4 x i32> @pinsrd_1(i32 %s, <4 x i32> %tmp) nounwind {
12 ; X86-SSE-LABEL: pinsrd_1:
14 ; X86-SSE-NEXT: pinsrd $1, {{[0-9]+}}(%esp), %xmm0 ## encoding: [0x66,0x0f,0x3a,0x22,0x44,0x24,0x04,0x01]
15 ; X86-SSE-NEXT: retl ## encoding: [0xc3]
17 ; X86-AVX1-LABEL: pinsrd_1:
19 ; X86-AVX1-NEXT: vpinsrd $1, {{[0-9]+}}(%esp), %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x22,0x44,0x24,0x04,0x01]
20 ; X86-AVX1-NEXT: retl ## encoding: [0xc3]
22 ; X86-AVX512-LABEL: pinsrd_1:
23 ; X86-AVX512: ## %bb.0:
24 ; X86-AVX512-NEXT: vpinsrd $1, {{[0-9]+}}(%esp), %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x22,0x44,0x24,0x04,0x01]
25 ; X86-AVX512-NEXT: retl ## encoding: [0xc3]
27 ; X64-SSE-LABEL: pinsrd_1:
29 ; X64-SSE-NEXT: pinsrd $1, %edi, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x22,0xc7,0x01]
30 ; X64-SSE-NEXT: retq ## encoding: [0xc3]
32 ; X64-AVX1-LABEL: pinsrd_1:
34 ; X64-AVX1-NEXT: vpinsrd $1, %edi, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x22,0xc7,0x01]
35 ; X64-AVX1-NEXT: retq ## encoding: [0xc3]
37 ; X64-AVX512-LABEL: pinsrd_1:
38 ; X64-AVX512: ## %bb.0:
39 ; X64-AVX512-NEXT: vpinsrd $1, %edi, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x22,0xc7,0x01]
40 ; X64-AVX512-NEXT: retq ## encoding: [0xc3]
41 %tmp1 = insertelement <4 x i32> %tmp, i32 %s, i32 1
45 define <16 x i8> @pinsrb_1(i8 %s, <16 x i8> %tmp) nounwind {
46 ; X86-SSE-LABEL: pinsrb_1:
48 ; X86-SSE-NEXT: pinsrb $1, {{[0-9]+}}(%esp), %xmm0 ## encoding: [0x66,0x0f,0x3a,0x20,0x44,0x24,0x04,0x01]
49 ; X86-SSE-NEXT: retl ## encoding: [0xc3]
51 ; X86-AVX1-LABEL: pinsrb_1:
53 ; X86-AVX1-NEXT: vpinsrb $1, {{[0-9]+}}(%esp), %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x20,0x44,0x24,0x04,0x01]
54 ; X86-AVX1-NEXT: retl ## encoding: [0xc3]
56 ; X86-AVX512-LABEL: pinsrb_1:
57 ; X86-AVX512: ## %bb.0:
58 ; X86-AVX512-NEXT: vpinsrb $1, {{[0-9]+}}(%esp), %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x20,0x44,0x24,0x04,0x01]
59 ; X86-AVX512-NEXT: retl ## encoding: [0xc3]
61 ; X64-SSE-LABEL: pinsrb_1:
63 ; X64-SSE-NEXT: pinsrb $1, %edi, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x20,0xc7,0x01]
64 ; X64-SSE-NEXT: retq ## encoding: [0xc3]
66 ; X64-AVX1-LABEL: pinsrb_1:
68 ; X64-AVX1-NEXT: vpinsrb $1, %edi, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x20,0xc7,0x01]
69 ; X64-AVX1-NEXT: retq ## encoding: [0xc3]
71 ; X64-AVX512-LABEL: pinsrb_1:
72 ; X64-AVX512: ## %bb.0:
73 ; X64-AVX512-NEXT: vpinsrb $1, %edi, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x20,0xc7,0x01]
74 ; X64-AVX512-NEXT: retq ## encoding: [0xc3]
75 %tmp1 = insertelement <16 x i8> %tmp, i8 %s, i32 1
79 define <2 x i64> @pmovzxbq_1() nounwind {
80 ; X86-SSE-LABEL: pmovzxbq_1:
81 ; X86-SSE: ## %bb.0: ## %entry
82 ; X86-SSE-NEXT: movl L_g16$non_lazy_ptr, %eax ## encoding: [0xa1,A,A,A,A]
83 ; X86-SSE-NEXT: ## fixup A - offset: 1, value: L_g16$non_lazy_ptr, kind: FK_Data_4
84 ; X86-SSE-NEXT: pmovzxbq (%eax), %xmm0 ## encoding: [0x66,0x0f,0x38,0x32,0x00]
85 ; X86-SSE-NEXT: ## xmm0 = mem[0],zero,zero,zero,zero,zero,zero,zero,mem[1],zero,zero,zero,zero,zero,zero,zero
86 ; X86-SSE-NEXT: retl ## encoding: [0xc3]
88 ; X86-AVX1-LABEL: pmovzxbq_1:
89 ; X86-AVX1: ## %bb.0: ## %entry
90 ; X86-AVX1-NEXT: movl L_g16$non_lazy_ptr, %eax ## encoding: [0xa1,A,A,A,A]
91 ; X86-AVX1-NEXT: ## fixup A - offset: 1, value: L_g16$non_lazy_ptr, kind: FK_Data_4
92 ; X86-AVX1-NEXT: vpmovzxbq (%eax), %xmm0 ## encoding: [0xc4,0xe2,0x79,0x32,0x00]
93 ; X86-AVX1-NEXT: ## xmm0 = mem[0],zero,zero,zero,zero,zero,zero,zero,mem[1],zero,zero,zero,zero,zero,zero,zero
94 ; X86-AVX1-NEXT: retl ## encoding: [0xc3]
96 ; X86-AVX512-LABEL: pmovzxbq_1:
97 ; X86-AVX512: ## %bb.0: ## %entry
98 ; X86-AVX512-NEXT: movl L_g16$non_lazy_ptr, %eax ## encoding: [0xa1,A,A,A,A]
99 ; X86-AVX512-NEXT: ## fixup A - offset: 1, value: L_g16$non_lazy_ptr, kind: FK_Data_4
100 ; X86-AVX512-NEXT: vpbroadcastw (%eax), %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe2,0x79,0x79,0x00]
101 ; X86-AVX512-NEXT: vpmovzxbq %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe2,0x79,0x32,0xc0]
102 ; X86-AVX512-NEXT: ## xmm0 = xmm0[0],zero,zero,zero,zero,zero,zero,zero,xmm0[1],zero,zero,zero,zero,zero,zero,zero
103 ; X86-AVX512-NEXT: retl ## encoding: [0xc3]
105 ; X64-SSE-LABEL: pmovzxbq_1:
106 ; X64-SSE: ## %bb.0: ## %entry
107 ; X64-SSE-NEXT: movq _g16@{{.*}}(%rip), %rax ## encoding: [0x48,0x8b,0x05,A,A,A,A]
108 ; X64-SSE-NEXT: ## fixup A - offset: 3, value: _g16@GOTPCREL-4, kind: reloc_riprel_4byte_movq_load
109 ; X64-SSE-NEXT: pmovzxbq (%rax), %xmm0 ## encoding: [0x66,0x0f,0x38,0x32,0x00]
110 ; X64-SSE-NEXT: ## xmm0 = mem[0],zero,zero,zero,zero,zero,zero,zero,mem[1],zero,zero,zero,zero,zero,zero,zero
111 ; X64-SSE-NEXT: retq ## encoding: [0xc3]
113 ; X64-AVX1-LABEL: pmovzxbq_1:
114 ; X64-AVX1: ## %bb.0: ## %entry
115 ; X64-AVX1-NEXT: movq _g16@{{.*}}(%rip), %rax ## encoding: [0x48,0x8b,0x05,A,A,A,A]
116 ; X64-AVX1-NEXT: ## fixup A - offset: 3, value: _g16@GOTPCREL-4, kind: reloc_riprel_4byte_movq_load
117 ; X64-AVX1-NEXT: vpmovzxbq (%rax), %xmm0 ## encoding: [0xc4,0xe2,0x79,0x32,0x00]
118 ; X64-AVX1-NEXT: ## xmm0 = mem[0],zero,zero,zero,zero,zero,zero,zero,mem[1],zero,zero,zero,zero,zero,zero,zero
119 ; X64-AVX1-NEXT: retq ## encoding: [0xc3]
121 ; X64-AVX512-LABEL: pmovzxbq_1:
122 ; X64-AVX512: ## %bb.0: ## %entry
123 ; X64-AVX512-NEXT: movq _g16@{{.*}}(%rip), %rax ## encoding: [0x48,0x8b,0x05,A,A,A,A]
124 ; X64-AVX512-NEXT: ## fixup A - offset: 3, value: _g16@GOTPCREL-4, kind: reloc_riprel_4byte_movq_load
125 ; X64-AVX512-NEXT: vpbroadcastw (%rax), %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe2,0x79,0x79,0x00]
126 ; X64-AVX512-NEXT: vpmovzxbq %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe2,0x79,0x32,0xc0]
127 ; X64-AVX512-NEXT: ## xmm0 = xmm0[0],zero,zero,zero,zero,zero,zero,zero,xmm0[1],zero,zero,zero,zero,zero,zero,zero
128 ; X64-AVX512-NEXT: retq ## encoding: [0xc3]
130 %0 = load i16, i16* @g16, align 2 ; <i16> [#uses=1]
131 %1 = insertelement <8 x i16> undef, i16 %0, i32 0 ; <<8 x i16>> [#uses=1]
132 %2 = bitcast <8 x i16> %1 to <16 x i8> ; <<16 x i8>> [#uses=1]
133 %3 = tail call <2 x i64> @llvm.x86.sse41.pmovzxbq(<16 x i8> %2) nounwind readnone ; <<2 x i64>> [#uses=1]
137 declare <2 x i64> @llvm.x86.sse41.pmovzxbq(<16 x i8>) nounwind readnone
139 define i32 @extractps_1(<4 x float> %v) nounwind {
140 ; SSE-LABEL: extractps_1:
142 ; SSE-NEXT: extractps $3, %xmm0, %eax ## encoding: [0x66,0x0f,0x3a,0x17,0xc0,0x03]
143 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
145 ; AVX1-LABEL: extractps_1:
147 ; AVX1-NEXT: vextractps $3, %xmm0, %eax ## encoding: [0xc4,0xe3,0x79,0x17,0xc0,0x03]
148 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
150 ; AVX512-LABEL: extractps_1:
152 ; AVX512-NEXT: vextractps $3, %xmm0, %eax ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x17,0xc0,0x03]
153 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
154 %s = extractelement <4 x float> %v, i32 3
155 %i = bitcast float %s to i32
158 define i32 @extractps_2(<4 x float> %v) nounwind {
159 ; SSE-LABEL: extractps_2:
161 ; SSE-NEXT: extractps $3, %xmm0, %eax ## encoding: [0x66,0x0f,0x3a,0x17,0xc0,0x03]
162 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
164 ; AVX1-LABEL: extractps_2:
166 ; AVX1-NEXT: vextractps $3, %xmm0, %eax ## encoding: [0xc4,0xe3,0x79,0x17,0xc0,0x03]
167 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
169 ; AVX512-LABEL: extractps_2:
171 ; AVX512-NEXT: vextractps $3, %xmm0, %eax ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x17,0xc0,0x03]
172 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
173 %t = bitcast <4 x float> %v to <4 x i32>
174 %s = extractelement <4 x i32> %t, i32 3
179 ; The non-store form of extractps puts its result into a GPR.
180 ; This makes it suitable for an extract from a <4 x float> that
181 ; is bitcasted to i32, but unsuitable for much of anything else.
183 define float @ext_1(<4 x float> %v) nounwind {
184 ; X86-SSE-LABEL: ext_1:
186 ; X86-SSE-NEXT: pushl %eax ## encoding: [0x50]
187 ; X86-SSE-NEXT: shufps $231, %xmm0, %xmm0 ## encoding: [0x0f,0xc6,0xc0,0xe7]
188 ; X86-SSE-NEXT: ## xmm0 = xmm0[3,1,2,3]
189 ; X86-SSE-NEXT: addss LCPI5_0, %xmm0 ## encoding: [0xf3,0x0f,0x58,0x05,A,A,A,A]
190 ; X86-SSE-NEXT: ## fixup A - offset: 4, value: LCPI5_0, kind: FK_Data_4
191 ; X86-SSE-NEXT: movss %xmm0, (%esp) ## encoding: [0xf3,0x0f,0x11,0x04,0x24]
192 ; X86-SSE-NEXT: flds (%esp) ## encoding: [0xd9,0x04,0x24]
193 ; X86-SSE-NEXT: popl %eax ## encoding: [0x58]
194 ; X86-SSE-NEXT: retl ## encoding: [0xc3]
196 ; X86-AVX1-LABEL: ext_1:
197 ; X86-AVX1: ## %bb.0:
198 ; X86-AVX1-NEXT: pushl %eax ## encoding: [0x50]
199 ; X86-AVX1-NEXT: vpermilps $231, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x04,0xc0,0xe7]
200 ; X86-AVX1-NEXT: ## xmm0 = xmm0[3,1,2,3]
201 ; X86-AVX1-NEXT: vaddss LCPI5_0, %xmm0, %xmm0 ## encoding: [0xc5,0xfa,0x58,0x05,A,A,A,A]
202 ; X86-AVX1-NEXT: ## fixup A - offset: 4, value: LCPI5_0, kind: FK_Data_4
203 ; X86-AVX1-NEXT: vmovss %xmm0, (%esp) ## encoding: [0xc5,0xfa,0x11,0x04,0x24]
204 ; X86-AVX1-NEXT: flds (%esp) ## encoding: [0xd9,0x04,0x24]
205 ; X86-AVX1-NEXT: popl %eax ## encoding: [0x58]
206 ; X86-AVX1-NEXT: retl ## encoding: [0xc3]
208 ; X86-AVX512-LABEL: ext_1:
209 ; X86-AVX512: ## %bb.0:
210 ; X86-AVX512-NEXT: pushl %eax ## encoding: [0x50]
211 ; X86-AVX512-NEXT: vpermilps $231, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x04,0xc0,0xe7]
212 ; X86-AVX512-NEXT: ## xmm0 = xmm0[3,1,2,3]
213 ; X86-AVX512-NEXT: vaddss LCPI5_0, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc5,0xfa,0x58,0x05,A,A,A,A]
214 ; X86-AVX512-NEXT: ## fixup A - offset: 4, value: LCPI5_0, kind: FK_Data_4
215 ; X86-AVX512-NEXT: vmovss %xmm0, (%esp) ## EVEX TO VEX Compression encoding: [0xc5,0xfa,0x11,0x04,0x24]
216 ; X86-AVX512-NEXT: flds (%esp) ## encoding: [0xd9,0x04,0x24]
217 ; X86-AVX512-NEXT: popl %eax ## encoding: [0x58]
218 ; X86-AVX512-NEXT: retl ## encoding: [0xc3]
220 ; X64-SSE-LABEL: ext_1:
222 ; X64-SSE-NEXT: shufps $231, %xmm0, %xmm0 ## encoding: [0x0f,0xc6,0xc0,0xe7]
223 ; X64-SSE-NEXT: ## xmm0 = xmm0[3,1,2,3]
224 ; X64-SSE-NEXT: addss {{.*}}(%rip), %xmm0 ## encoding: [0xf3,0x0f,0x58,0x05,A,A,A,A]
225 ; X64-SSE-NEXT: ## fixup A - offset: 4, value: LCPI5_0-4, kind: reloc_riprel_4byte
226 ; X64-SSE-NEXT: retq ## encoding: [0xc3]
228 ; X64-AVX1-LABEL: ext_1:
229 ; X64-AVX1: ## %bb.0:
230 ; X64-AVX1-NEXT: vpermilps $231, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x04,0xc0,0xe7]
231 ; X64-AVX1-NEXT: ## xmm0 = xmm0[3,1,2,3]
232 ; X64-AVX1-NEXT: vaddss {{.*}}(%rip), %xmm0, %xmm0 ## encoding: [0xc5,0xfa,0x58,0x05,A,A,A,A]
233 ; X64-AVX1-NEXT: ## fixup A - offset: 4, value: LCPI5_0-4, kind: reloc_riprel_4byte
234 ; X64-AVX1-NEXT: retq ## encoding: [0xc3]
236 ; X64-AVX512-LABEL: ext_1:
237 ; X64-AVX512: ## %bb.0:
238 ; X64-AVX512-NEXT: vpermilps $231, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x04,0xc0,0xe7]
239 ; X64-AVX512-NEXT: ## xmm0 = xmm0[3,1,2,3]
240 ; X64-AVX512-NEXT: vaddss {{.*}}(%rip), %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc5,0xfa,0x58,0x05,A,A,A,A]
241 ; X64-AVX512-NEXT: ## fixup A - offset: 4, value: LCPI5_0-4, kind: reloc_riprel_4byte
242 ; X64-AVX512-NEXT: retq ## encoding: [0xc3]
243 %s = extractelement <4 x float> %v, i32 3
244 %t = fadd float %s, 1.0
248 define float @ext_2(<4 x float> %v) nounwind {
249 ; X86-SSE-LABEL: ext_2:
251 ; X86-SSE-NEXT: pushl %eax ## encoding: [0x50]
252 ; X86-SSE-NEXT: shufps $231, %xmm0, %xmm0 ## encoding: [0x0f,0xc6,0xc0,0xe7]
253 ; X86-SSE-NEXT: ## xmm0 = xmm0[3,1,2,3]
254 ; X86-SSE-NEXT: movss %xmm0, (%esp) ## encoding: [0xf3,0x0f,0x11,0x04,0x24]
255 ; X86-SSE-NEXT: flds (%esp) ## encoding: [0xd9,0x04,0x24]
256 ; X86-SSE-NEXT: popl %eax ## encoding: [0x58]
257 ; X86-SSE-NEXT: retl ## encoding: [0xc3]
259 ; X86-AVX1-LABEL: ext_2:
260 ; X86-AVX1: ## %bb.0:
261 ; X86-AVX1-NEXT: pushl %eax ## encoding: [0x50]
262 ; X86-AVX1-NEXT: vpermilps $231, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x04,0xc0,0xe7]
263 ; X86-AVX1-NEXT: ## xmm0 = xmm0[3,1,2,3]
264 ; X86-AVX1-NEXT: vmovss %xmm0, (%esp) ## encoding: [0xc5,0xfa,0x11,0x04,0x24]
265 ; X86-AVX1-NEXT: flds (%esp) ## encoding: [0xd9,0x04,0x24]
266 ; X86-AVX1-NEXT: popl %eax ## encoding: [0x58]
267 ; X86-AVX1-NEXT: retl ## encoding: [0xc3]
269 ; X86-AVX512-LABEL: ext_2:
270 ; X86-AVX512: ## %bb.0:
271 ; X86-AVX512-NEXT: pushl %eax ## encoding: [0x50]
272 ; X86-AVX512-NEXT: vpermilps $231, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x04,0xc0,0xe7]
273 ; X86-AVX512-NEXT: ## xmm0 = xmm0[3,1,2,3]
274 ; X86-AVX512-NEXT: vmovss %xmm0, (%esp) ## EVEX TO VEX Compression encoding: [0xc5,0xfa,0x11,0x04,0x24]
275 ; X86-AVX512-NEXT: flds (%esp) ## encoding: [0xd9,0x04,0x24]
276 ; X86-AVX512-NEXT: popl %eax ## encoding: [0x58]
277 ; X86-AVX512-NEXT: retl ## encoding: [0xc3]
279 ; X64-SSE-LABEL: ext_2:
281 ; X64-SSE-NEXT: shufps $231, %xmm0, %xmm0 ## encoding: [0x0f,0xc6,0xc0,0xe7]
282 ; X64-SSE-NEXT: ## xmm0 = xmm0[3,1,2,3]
283 ; X64-SSE-NEXT: retq ## encoding: [0xc3]
285 ; X64-AVX1-LABEL: ext_2:
286 ; X64-AVX1: ## %bb.0:
287 ; X64-AVX1-NEXT: vpermilps $231, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x04,0xc0,0xe7]
288 ; X64-AVX1-NEXT: ## xmm0 = xmm0[3,1,2,3]
289 ; X64-AVX1-NEXT: retq ## encoding: [0xc3]
291 ; X64-AVX512-LABEL: ext_2:
292 ; X64-AVX512: ## %bb.0:
293 ; X64-AVX512-NEXT: vpermilps $231, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x04,0xc0,0xe7]
294 ; X64-AVX512-NEXT: ## xmm0 = xmm0[3,1,2,3]
295 ; X64-AVX512-NEXT: retq ## encoding: [0xc3]
296 %s = extractelement <4 x float> %v, i32 3
300 define i32 @ext_3(<4 x i32> %v) nounwind {
303 ; SSE-NEXT: extractps $3, %xmm0, %eax ## encoding: [0x66,0x0f,0x3a,0x17,0xc0,0x03]
304 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
308 ; AVX1-NEXT: vextractps $3, %xmm0, %eax ## encoding: [0xc4,0xe3,0x79,0x17,0xc0,0x03]
309 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
311 ; AVX512-LABEL: ext_3:
313 ; AVX512-NEXT: vextractps $3, %xmm0, %eax ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x17,0xc0,0x03]
314 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
315 %i = extractelement <4 x i32> %v, i32 3
319 define <4 x float> @insertps_1(<4 x float> %t1, <4 x float> %t2) nounwind {
320 ; SSE-LABEL: insertps_1:
322 ; SSE-NEXT: insertps $21, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x21,0xc1,0x15]
323 ; SSE-NEXT: ## xmm0 = zero,xmm1[0],zero,xmm0[3]
324 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
326 ; AVX1-LABEL: insertps_1:
328 ; AVX1-NEXT: vinsertps $21, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x21,0xc1,0x15]
329 ; AVX1-NEXT: ## xmm0 = zero,xmm1[0],zero,xmm0[3]
330 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
332 ; AVX512-LABEL: insertps_1:
334 ; AVX512-NEXT: vinsertps $21, %xmm1, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x21,0xc1,0x15]
335 ; AVX512-NEXT: ## xmm0 = zero,xmm1[0],zero,xmm0[3]
336 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
337 %tmp1 = call <4 x float> @llvm.x86.sse41.insertps(<4 x float> %t1, <4 x float> %t2, i32 21) nounwind readnone
338 ret <4 x float> %tmp1
341 declare <4 x float> @llvm.x86.sse41.insertps(<4 x float>, <4 x float>, i32) nounwind readnone
343 ; When optimizing for speed, prefer blendps over insertps even if it means we have to
344 ; generate a separate movss to load the scalar operand.
345 define <4 x float> @blendps_not_insertps_1(<4 x float> %t1, float %t2) nounwind {
346 ; X86-SSE-LABEL: blendps_not_insertps_1:
348 ; X86-SSE-NEXT: movss {{[0-9]+}}(%esp), %xmm1 ## encoding: [0xf3,0x0f,0x10,0x4c,0x24,0x04]
349 ; X86-SSE-NEXT: ## xmm1 = mem[0],zero,zero,zero
350 ; X86-SSE-NEXT: blendps $1, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x0c,0xc1,0x01]
351 ; X86-SSE-NEXT: ## xmm0 = xmm1[0],xmm0[1,2,3]
352 ; X86-SSE-NEXT: retl ## encoding: [0xc3]
354 ; X86-AVX1-LABEL: blendps_not_insertps_1:
355 ; X86-AVX1: ## %bb.0:
356 ; X86-AVX1-NEXT: vmovss {{[0-9]+}}(%esp), %xmm1 ## encoding: [0xc5,0xfa,0x10,0x4c,0x24,0x04]
357 ; X86-AVX1-NEXT: ## xmm1 = mem[0],zero,zero,zero
358 ; X86-AVX1-NEXT: vblendps $1, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x0c,0xc1,0x01]
359 ; X86-AVX1-NEXT: ## xmm0 = xmm1[0],xmm0[1,2,3]
360 ; X86-AVX1-NEXT: retl ## encoding: [0xc3]
362 ; X86-AVX512-LABEL: blendps_not_insertps_1:
363 ; X86-AVX512: ## %bb.0:
364 ; X86-AVX512-NEXT: vmovss {{[0-9]+}}(%esp), %xmm1 ## EVEX TO VEX Compression encoding: [0xc5,0xfa,0x10,0x4c,0x24,0x04]
365 ; X86-AVX512-NEXT: ## xmm1 = mem[0],zero,zero,zero
366 ; X86-AVX512-NEXT: vblendps $1, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x0c,0xc1,0x01]
367 ; X86-AVX512-NEXT: ## xmm0 = xmm1[0],xmm0[1,2,3]
368 ; X86-AVX512-NEXT: retl ## encoding: [0xc3]
370 ; X64-SSE-LABEL: blendps_not_insertps_1:
372 ; X64-SSE-NEXT: blendps $1, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x0c,0xc1,0x01]
373 ; X64-SSE-NEXT: ## xmm0 = xmm1[0],xmm0[1,2,3]
374 ; X64-SSE-NEXT: retq ## encoding: [0xc3]
376 ; X64-AVX-LABEL: blendps_not_insertps_1:
378 ; X64-AVX-NEXT: vblendps $1, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x0c,0xc1,0x01]
379 ; X64-AVX-NEXT: ## xmm0 = xmm1[0],xmm0[1,2,3]
380 ; X64-AVX-NEXT: retq ## encoding: [0xc3]
381 %tmp1 = insertelement <4 x float> %t1, float %t2, i32 0
382 ret <4 x float> %tmp1
385 ; When optimizing for size, generate an insertps if there's a load fold opportunity.
386 ; The difference between i386 and x86-64 ABIs for the float operand means we should
387 ; generate an insertps for X86 but not for X64!
388 define <4 x float> @insertps_or_blendps(<4 x float> %t1, float %t2) minsize nounwind {
389 ; X86-SSE-LABEL: insertps_or_blendps:
391 ; X86-SSE-NEXT: movss {{[0-9]+}}(%esp), %xmm1 ## encoding: [0xf3,0x0f,0x10,0x4c,0x24,0x04]
392 ; X86-SSE-NEXT: ## xmm1 = mem[0],zero,zero,zero
393 ; X86-SSE-NEXT: movss %xmm1, %xmm0 ## encoding: [0xf3,0x0f,0x10,0xc1]
394 ; X86-SSE-NEXT: ## xmm0 = xmm1[0],xmm0[1,2,3]
395 ; X86-SSE-NEXT: retl ## encoding: [0xc3]
397 ; X86-AVX1-LABEL: insertps_or_blendps:
398 ; X86-AVX1: ## %bb.0:
399 ; X86-AVX1-NEXT: vmovss {{[0-9]+}}(%esp), %xmm1 ## encoding: [0xc5,0xfa,0x10,0x4c,0x24,0x04]
400 ; X86-AVX1-NEXT: ## xmm1 = mem[0],zero,zero,zero
401 ; X86-AVX1-NEXT: vmovss %xmm1, %xmm0, %xmm0 ## encoding: [0xc5,0xfa,0x10,0xc1]
402 ; X86-AVX1-NEXT: ## xmm0 = xmm1[0],xmm0[1,2,3]
403 ; X86-AVX1-NEXT: retl ## encoding: [0xc3]
405 ; X86-AVX512-LABEL: insertps_or_blendps:
406 ; X86-AVX512: ## %bb.0:
407 ; X86-AVX512-NEXT: vmovss {{[0-9]+}}(%esp), %xmm1 ## EVEX TO VEX Compression encoding: [0xc5,0xfa,0x10,0x4c,0x24,0x04]
408 ; X86-AVX512-NEXT: ## xmm1 = mem[0],zero,zero,zero
409 ; X86-AVX512-NEXT: vmovss %xmm1, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc5,0xfa,0x10,0xc1]
410 ; X86-AVX512-NEXT: ## xmm0 = xmm1[0],xmm0[1,2,3]
411 ; X86-AVX512-NEXT: retl ## encoding: [0xc3]
413 ; X64-SSE-LABEL: insertps_or_blendps:
415 ; X64-SSE-NEXT: movss %xmm1, %xmm0 ## encoding: [0xf3,0x0f,0x10,0xc1]
416 ; X64-SSE-NEXT: ## xmm0 = xmm1[0],xmm0[1,2,3]
417 ; X64-SSE-NEXT: retq ## encoding: [0xc3]
419 ; X64-AVX1-LABEL: insertps_or_blendps:
420 ; X64-AVX1: ## %bb.0:
421 ; X64-AVX1-NEXT: vmovss %xmm1, %xmm0, %xmm0 ## encoding: [0xc5,0xfa,0x10,0xc1]
422 ; X64-AVX1-NEXT: ## xmm0 = xmm1[0],xmm0[1,2,3]
423 ; X64-AVX1-NEXT: retq ## encoding: [0xc3]
425 ; X64-AVX512-LABEL: insertps_or_blendps:
426 ; X64-AVX512: ## %bb.0:
427 ; X64-AVX512-NEXT: vmovss %xmm1, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc5,0xfa,0x10,0xc1]
428 ; X64-AVX512-NEXT: ## xmm0 = xmm1[0],xmm0[1,2,3]
429 ; X64-AVX512-NEXT: retq ## encoding: [0xc3]
430 %tmp1 = insertelement <4 x float> %t1, float %t2, i32 0
431 ret <4 x float> %tmp1
434 ; An insert into the low 32-bits of a vector from the low 32-bits of another vector
435 ; is always just a blendps because blendps is never more expensive than insertps.
436 define <4 x float> @blendps_not_insertps_2(<4 x float> %t1, <4 x float> %t2) nounwind {
437 ; SSE-LABEL: blendps_not_insertps_2:
439 ; SSE-NEXT: blendps $1, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x0c,0xc1,0x01]
440 ; SSE-NEXT: ## xmm0 = xmm1[0],xmm0[1,2,3]
441 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
443 ; AVX-LABEL: blendps_not_insertps_2:
445 ; AVX-NEXT: vblendps $1, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x0c,0xc1,0x01]
446 ; AVX-NEXT: ## xmm0 = xmm1[0],xmm0[1,2,3]
447 ; AVX-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
448 %tmp2 = extractelement <4 x float> %t2, i32 0
449 %tmp1 = insertelement <4 x float> %t1, float %tmp2, i32 0
450 ret <4 x float> %tmp1
453 define i32 @ptestz_1(<2 x i64> %t1, <2 x i64> %t2) nounwind {
454 ; SSE-LABEL: ptestz_1:
456 ; SSE-NEXT: xorl %eax, %eax ## encoding: [0x31,0xc0]
457 ; SSE-NEXT: ptest %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x38,0x17,0xc1]
458 ; SSE-NEXT: sete %al ## encoding: [0x0f,0x94,0xc0]
459 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
461 ; AVX-LABEL: ptestz_1:
463 ; AVX-NEXT: xorl %eax, %eax ## encoding: [0x31,0xc0]
464 ; AVX-NEXT: vptest %xmm1, %xmm0 ## encoding: [0xc4,0xe2,0x79,0x17,0xc1]
465 ; AVX-NEXT: sete %al ## encoding: [0x0f,0x94,0xc0]
466 ; AVX-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
467 %tmp1 = call i32 @llvm.x86.sse41.ptestz(<2 x i64> %t1, <2 x i64> %t2) nounwind readnone
471 define i32 @ptestz_2(<2 x i64> %t1, <2 x i64> %t2) nounwind {
472 ; SSE-LABEL: ptestz_2:
474 ; SSE-NEXT: xorl %eax, %eax ## encoding: [0x31,0xc0]
475 ; SSE-NEXT: ptest %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x38,0x17,0xc1]
476 ; SSE-NEXT: setb %al ## encoding: [0x0f,0x92,0xc0]
477 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
479 ; AVX-LABEL: ptestz_2:
481 ; AVX-NEXT: xorl %eax, %eax ## encoding: [0x31,0xc0]
482 ; AVX-NEXT: vptest %xmm1, %xmm0 ## encoding: [0xc4,0xe2,0x79,0x17,0xc1]
483 ; AVX-NEXT: setb %al ## encoding: [0x0f,0x92,0xc0]
484 ; AVX-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
485 %tmp1 = call i32 @llvm.x86.sse41.ptestc(<2 x i64> %t1, <2 x i64> %t2) nounwind readnone
489 define i32 @ptestz_3(<2 x i64> %t1, <2 x i64> %t2) nounwind {
490 ; SSE-LABEL: ptestz_3:
492 ; SSE-NEXT: xorl %eax, %eax ## encoding: [0x31,0xc0]
493 ; SSE-NEXT: ptest %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x38,0x17,0xc1]
494 ; SSE-NEXT: seta %al ## encoding: [0x0f,0x97,0xc0]
495 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
497 ; AVX-LABEL: ptestz_3:
499 ; AVX-NEXT: xorl %eax, %eax ## encoding: [0x31,0xc0]
500 ; AVX-NEXT: vptest %xmm1, %xmm0 ## encoding: [0xc4,0xe2,0x79,0x17,0xc1]
501 ; AVX-NEXT: seta %al ## encoding: [0x0f,0x97,0xc0]
502 ; AVX-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
503 %tmp1 = call i32 @llvm.x86.sse41.ptestnzc(<2 x i64> %t1, <2 x i64> %t2) nounwind readnone
507 declare i32 @llvm.x86.sse41.ptestz(<2 x i64>, <2 x i64>) nounwind readnone
508 declare i32 @llvm.x86.sse41.ptestc(<2 x i64>, <2 x i64>) nounwind readnone
509 declare i32 @llvm.x86.sse41.ptestnzc(<2 x i64>, <2 x i64>) nounwind readnone
511 ; This used to compile to insertps $0 + insertps $16. insertps $0 is always
513 define <2 x float> @buildvector(<2 x float> %A, <2 x float> %B) nounwind {
514 ; SSE-LABEL: buildvector:
515 ; SSE: ## %bb.0: ## %entry
516 ; SSE-NEXT: movshdup %xmm0, %xmm2 ## encoding: [0xf3,0x0f,0x16,0xd0]
517 ; SSE-NEXT: ## xmm2 = xmm0[1,1,3,3]
518 ; SSE-NEXT: movshdup %xmm1, %xmm3 ## encoding: [0xf3,0x0f,0x16,0xd9]
519 ; SSE-NEXT: ## xmm3 = xmm1[1,1,3,3]
520 ; SSE-NEXT: addss %xmm2, %xmm3 ## encoding: [0xf3,0x0f,0x58,0xda]
521 ; SSE-NEXT: addss %xmm1, %xmm0 ## encoding: [0xf3,0x0f,0x58,0xc1]
522 ; SSE-NEXT: insertps $16, %xmm3, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x21,0xc3,0x10]
523 ; SSE-NEXT: ## xmm0 = xmm0[0],xmm3[0],xmm0[2,3]
524 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
526 ; AVX1-LABEL: buildvector:
527 ; AVX1: ## %bb.0: ## %entry
528 ; AVX1-NEXT: vmovshdup %xmm0, %xmm2 ## encoding: [0xc5,0xfa,0x16,0xd0]
529 ; AVX1-NEXT: ## xmm2 = xmm0[1,1,3,3]
530 ; AVX1-NEXT: vmovshdup %xmm1, %xmm3 ## encoding: [0xc5,0xfa,0x16,0xd9]
531 ; AVX1-NEXT: ## xmm3 = xmm1[1,1,3,3]
532 ; AVX1-NEXT: vaddss %xmm3, %xmm2, %xmm2 ## encoding: [0xc5,0xea,0x58,0xd3]
533 ; AVX1-NEXT: vaddss %xmm1, %xmm0, %xmm0 ## encoding: [0xc5,0xfa,0x58,0xc1]
534 ; AVX1-NEXT: vinsertps $16, %xmm2, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x21,0xc2,0x10]
535 ; AVX1-NEXT: ## xmm0 = xmm0[0],xmm2[0],xmm0[2,3]
536 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
538 ; AVX512-LABEL: buildvector:
539 ; AVX512: ## %bb.0: ## %entry
540 ; AVX512-NEXT: vmovshdup %xmm0, %xmm2 ## EVEX TO VEX Compression encoding: [0xc5,0xfa,0x16,0xd0]
541 ; AVX512-NEXT: ## xmm2 = xmm0[1,1,3,3]
542 ; AVX512-NEXT: vmovshdup %xmm1, %xmm3 ## EVEX TO VEX Compression encoding: [0xc5,0xfa,0x16,0xd9]
543 ; AVX512-NEXT: ## xmm3 = xmm1[1,1,3,3]
544 ; AVX512-NEXT: vaddss %xmm3, %xmm2, %xmm2 ## EVEX TO VEX Compression encoding: [0xc5,0xea,0x58,0xd3]
545 ; AVX512-NEXT: vaddss %xmm1, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc5,0xfa,0x58,0xc1]
546 ; AVX512-NEXT: vinsertps $16, %xmm2, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x21,0xc2,0x10]
547 ; AVX512-NEXT: ## xmm0 = xmm0[0],xmm2[0],xmm0[2,3]
548 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
550 %tmp7 = extractelement <2 x float> %A, i32 0
551 %tmp5 = extractelement <2 x float> %A, i32 1
552 %tmp3 = extractelement <2 x float> %B, i32 0
553 %tmp1 = extractelement <2 x float> %B, i32 1
554 %add.r = fadd float %tmp7, %tmp3
555 %add.i = fadd float %tmp5, %tmp1
556 %tmp11 = insertelement <2 x float> undef, float %add.r, i32 0
557 %tmp9 = insertelement <2 x float> %tmp11, float %add.i, i32 1
558 ret <2 x float> %tmp9
561 define <4 x float> @insertps_from_shufflevector_1(<4 x float> %a, <4 x float>* nocapture readonly %pb) {
562 ; X86-SSE-LABEL: insertps_from_shufflevector_1:
563 ; X86-SSE: ## %bb.0: ## %entry
564 ; X86-SSE-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
565 ; X86-SSE-NEXT: movaps (%eax), %xmm1 ## encoding: [0x0f,0x28,0x08]
566 ; X86-SSE-NEXT: insertps $48, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x21,0xc1,0x30]
567 ; X86-SSE-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[0]
568 ; X86-SSE-NEXT: retl ## encoding: [0xc3]
570 ; X86-AVX1-LABEL: insertps_from_shufflevector_1:
571 ; X86-AVX1: ## %bb.0: ## %entry
572 ; X86-AVX1-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
573 ; X86-AVX1-NEXT: vmovaps (%eax), %xmm1 ## encoding: [0xc5,0xf8,0x28,0x08]
574 ; X86-AVX1-NEXT: vinsertps $48, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x21,0xc1,0x30]
575 ; X86-AVX1-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[0]
576 ; X86-AVX1-NEXT: retl ## encoding: [0xc3]
578 ; X86-AVX512-LABEL: insertps_from_shufflevector_1:
579 ; X86-AVX512: ## %bb.0: ## %entry
580 ; X86-AVX512-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
581 ; X86-AVX512-NEXT: vmovaps (%eax), %xmm1 ## EVEX TO VEX Compression encoding: [0xc5,0xf8,0x28,0x08]
582 ; X86-AVX512-NEXT: vinsertps $48, %xmm1, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x21,0xc1,0x30]
583 ; X86-AVX512-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[0]
584 ; X86-AVX512-NEXT: retl ## encoding: [0xc3]
586 ; X64-SSE-LABEL: insertps_from_shufflevector_1:
587 ; X64-SSE: ## %bb.0: ## %entry
588 ; X64-SSE-NEXT: movaps (%rdi), %xmm1 ## encoding: [0x0f,0x28,0x0f]
589 ; X64-SSE-NEXT: insertps $48, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x21,0xc1,0x30]
590 ; X64-SSE-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[0]
591 ; X64-SSE-NEXT: retq ## encoding: [0xc3]
593 ; X64-AVX1-LABEL: insertps_from_shufflevector_1:
594 ; X64-AVX1: ## %bb.0: ## %entry
595 ; X64-AVX1-NEXT: vmovaps (%rdi), %xmm1 ## encoding: [0xc5,0xf8,0x28,0x0f]
596 ; X64-AVX1-NEXT: vinsertps $48, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x21,0xc1,0x30]
597 ; X64-AVX1-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[0]
598 ; X64-AVX1-NEXT: retq ## encoding: [0xc3]
600 ; X64-AVX512-LABEL: insertps_from_shufflevector_1:
601 ; X64-AVX512: ## %bb.0: ## %entry
602 ; X64-AVX512-NEXT: vmovaps (%rdi), %xmm1 ## EVEX TO VEX Compression encoding: [0xc5,0xf8,0x28,0x0f]
603 ; X64-AVX512-NEXT: vinsertps $48, %xmm1, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x21,0xc1,0x30]
604 ; X64-AVX512-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[0]
605 ; X64-AVX512-NEXT: retq ## encoding: [0xc3]
607 %0 = load <4 x float>, <4 x float>* %pb, align 16
608 %vecinit6 = shufflevector <4 x float> %a, <4 x float> %0, <4 x i32> <i32 0, i32 1, i32 2, i32 4>
609 ret <4 x float> %vecinit6
612 define <4 x float> @insertps_from_shufflevector_2(<4 x float> %a, <4 x float> %b) {
613 ; SSE-LABEL: insertps_from_shufflevector_2:
614 ; SSE: ## %bb.0: ## %entry
615 ; SSE-NEXT: insertps $96, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x21,0xc1,0x60]
616 ; SSE-NEXT: ## xmm0 = xmm0[0,1],xmm1[1],xmm0[3]
617 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
619 ; AVX1-LABEL: insertps_from_shufflevector_2:
620 ; AVX1: ## %bb.0: ## %entry
621 ; AVX1-NEXT: vinsertps $96, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x21,0xc1,0x60]
622 ; AVX1-NEXT: ## xmm0 = xmm0[0,1],xmm1[1],xmm0[3]
623 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
625 ; AVX512-LABEL: insertps_from_shufflevector_2:
626 ; AVX512: ## %bb.0: ## %entry
627 ; AVX512-NEXT: vinsertps $96, %xmm1, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x21,0xc1,0x60]
628 ; AVX512-NEXT: ## xmm0 = xmm0[0,1],xmm1[1],xmm0[3]
629 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
631 %vecinit6 = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 1, i32 5, i32 3>
632 ret <4 x float> %vecinit6
635 ; For loading an i32 from memory into an xmm register we use pinsrd
636 ; instead of insertps
637 define <4 x i32> @pinsrd_from_shufflevector_i32(<4 x i32> %a, <4 x i32>* nocapture readonly %pb) {
638 ; X86-SSE-LABEL: pinsrd_from_shufflevector_i32:
639 ; X86-SSE: ## %bb.0: ## %entry
640 ; X86-SSE-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
641 ; X86-SSE-NEXT: pshufd $36, (%eax), %xmm1 ## encoding: [0x66,0x0f,0x70,0x08,0x24]
642 ; X86-SSE-NEXT: ## xmm1 = mem[0,1,2,0]
643 ; X86-SSE-NEXT: pblendw $192, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x0e,0xc1,0xc0]
644 ; X86-SSE-NEXT: ## xmm0 = xmm0[0,1,2,3,4,5],xmm1[6,7]
645 ; X86-SSE-NEXT: retl ## encoding: [0xc3]
647 ; X86-AVX1-LABEL: pinsrd_from_shufflevector_i32:
648 ; X86-AVX1: ## %bb.0: ## %entry
649 ; X86-AVX1-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
650 ; X86-AVX1-NEXT: vpermilps $36, (%eax), %xmm1 ## encoding: [0xc4,0xe3,0x79,0x04,0x08,0x24]
651 ; X86-AVX1-NEXT: ## xmm1 = mem[0,1,2,0]
652 ; X86-AVX1-NEXT: vblendps $8, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x0c,0xc1,0x08]
653 ; X86-AVX1-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[3]
654 ; X86-AVX1-NEXT: retl ## encoding: [0xc3]
656 ; X86-AVX512-LABEL: pinsrd_from_shufflevector_i32:
657 ; X86-AVX512: ## %bb.0: ## %entry
658 ; X86-AVX512-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
659 ; X86-AVX512-NEXT: vbroadcastss (%eax), %xmm1 ## EVEX TO VEX Compression encoding: [0xc4,0xe2,0x79,0x18,0x08]
660 ; X86-AVX512-NEXT: vblendps $8, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x0c,0xc1,0x08]
661 ; X86-AVX512-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[3]
662 ; X86-AVX512-NEXT: retl ## encoding: [0xc3]
664 ; X64-SSE-LABEL: pinsrd_from_shufflevector_i32:
665 ; X64-SSE: ## %bb.0: ## %entry
666 ; X64-SSE-NEXT: pshufd $36, (%rdi), %xmm1 ## encoding: [0x66,0x0f,0x70,0x0f,0x24]
667 ; X64-SSE-NEXT: ## xmm1 = mem[0,1,2,0]
668 ; X64-SSE-NEXT: pblendw $192, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x0e,0xc1,0xc0]
669 ; X64-SSE-NEXT: ## xmm0 = xmm0[0,1,2,3,4,5],xmm1[6,7]
670 ; X64-SSE-NEXT: retq ## encoding: [0xc3]
672 ; X64-AVX1-LABEL: pinsrd_from_shufflevector_i32:
673 ; X64-AVX1: ## %bb.0: ## %entry
674 ; X64-AVX1-NEXT: vpermilps $36, (%rdi), %xmm1 ## encoding: [0xc4,0xe3,0x79,0x04,0x0f,0x24]
675 ; X64-AVX1-NEXT: ## xmm1 = mem[0,1,2,0]
676 ; X64-AVX1-NEXT: vblendps $8, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x0c,0xc1,0x08]
677 ; X64-AVX1-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[3]
678 ; X64-AVX1-NEXT: retq ## encoding: [0xc3]
680 ; X64-AVX512-LABEL: pinsrd_from_shufflevector_i32:
681 ; X64-AVX512: ## %bb.0: ## %entry
682 ; X64-AVX512-NEXT: vbroadcastss (%rdi), %xmm1 ## EVEX TO VEX Compression encoding: [0xc4,0xe2,0x79,0x18,0x0f]
683 ; X64-AVX512-NEXT: vblendps $8, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x0c,0xc1,0x08]
684 ; X64-AVX512-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[3]
685 ; X64-AVX512-NEXT: retq ## encoding: [0xc3]
687 %0 = load <4 x i32>, <4 x i32>* %pb, align 16
688 %vecinit6 = shufflevector <4 x i32> %a, <4 x i32> %0, <4 x i32> <i32 0, i32 1, i32 2, i32 4>
689 ret <4 x i32> %vecinit6
692 define <4 x i32> @insertps_from_shufflevector_i32_2(<4 x i32> %a, <4 x i32> %b) {
693 ; SSE-LABEL: insertps_from_shufflevector_i32_2:
694 ; SSE: ## %bb.0: ## %entry
695 ; SSE-NEXT: pshufd $78, %xmm1, %xmm1 ## encoding: [0x66,0x0f,0x70,0xc9,0x4e]
696 ; SSE-NEXT: ## xmm1 = xmm1[2,3,0,1]
697 ; SSE-NEXT: pblendw $12, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x0e,0xc1,0x0c]
698 ; SSE-NEXT: ## xmm0 = xmm0[0,1],xmm1[2,3],xmm0[4,5,6,7]
699 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
701 ; AVX1-LABEL: insertps_from_shufflevector_i32_2:
702 ; AVX1: ## %bb.0: ## %entry
703 ; AVX1-NEXT: vpermilps $78, %xmm1, %xmm1 ## encoding: [0xc4,0xe3,0x79,0x04,0xc9,0x4e]
704 ; AVX1-NEXT: ## xmm1 = xmm1[2,3,0,1]
705 ; AVX1-NEXT: vblendps $2, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x0c,0xc1,0x02]
706 ; AVX1-NEXT: ## xmm0 = xmm0[0],xmm1[1],xmm0[2,3]
707 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
709 ; AVX512-LABEL: insertps_from_shufflevector_i32_2:
710 ; AVX512: ## %bb.0: ## %entry
711 ; AVX512-NEXT: vpermilps $78, %xmm1, %xmm1 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x04,0xc9,0x4e]
712 ; AVX512-NEXT: ## xmm1 = xmm1[2,3,0,1]
713 ; AVX512-NEXT: vblendps $2, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x0c,0xc1,0x02]
714 ; AVX512-NEXT: ## xmm0 = xmm0[0],xmm1[1],xmm0[2,3]
715 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
717 %vecinit6 = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 7, i32 2, i32 3>
718 ret <4 x i32> %vecinit6
721 define <4 x float> @insertps_from_load_ins_elt_undef(<4 x float> %a, float* %b) {
722 ; X86-SSE-LABEL: insertps_from_load_ins_elt_undef:
724 ; X86-SSE-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
725 ; X86-SSE-NEXT: insertps $16, (%eax), %xmm0 ## encoding: [0x66,0x0f,0x3a,0x21,0x00,0x10]
726 ; X86-SSE-NEXT: ## xmm0 = xmm0[0],mem[0],xmm0[2,3]
727 ; X86-SSE-NEXT: retl ## encoding: [0xc3]
729 ; X86-AVX1-LABEL: insertps_from_load_ins_elt_undef:
730 ; X86-AVX1: ## %bb.0:
731 ; X86-AVX1-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
732 ; X86-AVX1-NEXT: vinsertps $16, (%eax), %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x21,0x00,0x10]
733 ; X86-AVX1-NEXT: ## xmm0 = xmm0[0],mem[0],xmm0[2,3]
734 ; X86-AVX1-NEXT: retl ## encoding: [0xc3]
736 ; X86-AVX512-LABEL: insertps_from_load_ins_elt_undef:
737 ; X86-AVX512: ## %bb.0:
738 ; X86-AVX512-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
739 ; X86-AVX512-NEXT: vinsertps $16, (%eax), %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x21,0x00,0x10]
740 ; X86-AVX512-NEXT: ## xmm0 = xmm0[0],mem[0],xmm0[2,3]
741 ; X86-AVX512-NEXT: retl ## encoding: [0xc3]
743 ; X64-SSE-LABEL: insertps_from_load_ins_elt_undef:
745 ; X64-SSE-NEXT: insertps $16, (%rdi), %xmm0 ## encoding: [0x66,0x0f,0x3a,0x21,0x07,0x10]
746 ; X64-SSE-NEXT: ## xmm0 = xmm0[0],mem[0],xmm0[2,3]
747 ; X64-SSE-NEXT: retq ## encoding: [0xc3]
749 ; X64-AVX1-LABEL: insertps_from_load_ins_elt_undef:
750 ; X64-AVX1: ## %bb.0:
751 ; X64-AVX1-NEXT: vinsertps $16, (%rdi), %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x21,0x07,0x10]
752 ; X64-AVX1-NEXT: ## xmm0 = xmm0[0],mem[0],xmm0[2,3]
753 ; X64-AVX1-NEXT: retq ## encoding: [0xc3]
755 ; X64-AVX512-LABEL: insertps_from_load_ins_elt_undef:
756 ; X64-AVX512: ## %bb.0:
757 ; X64-AVX512-NEXT: vinsertps $16, (%rdi), %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x21,0x07,0x10]
758 ; X64-AVX512-NEXT: ## xmm0 = xmm0[0],mem[0],xmm0[2,3]
759 ; X64-AVX512-NEXT: retq ## encoding: [0xc3]
760 %1 = load float, float* %b, align 4
761 %2 = insertelement <4 x float> undef, float %1, i32 0
762 %result = shufflevector <4 x float> %a, <4 x float> %2, <4 x i32> <i32 0, i32 4, i32 2, i32 3>
763 ret <4 x float> %result
766 ; TODO: Like on pinsrd_from_shufflevector_i32, remove this mov instr
767 define <4 x i32> @insertps_from_load_ins_elt_undef_i32(<4 x i32> %a, i32* %b) {
768 ; X86-SSE-LABEL: insertps_from_load_ins_elt_undef_i32:
770 ; X86-SSE-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
771 ; X86-SSE-NEXT: pinsrd $2, (%eax), %xmm0 ## encoding: [0x66,0x0f,0x3a,0x22,0x00,0x02]
772 ; X86-SSE-NEXT: retl ## encoding: [0xc3]
774 ; X86-AVX1-LABEL: insertps_from_load_ins_elt_undef_i32:
775 ; X86-AVX1: ## %bb.0:
776 ; X86-AVX1-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
777 ; X86-AVX1-NEXT: vpinsrd $2, (%eax), %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x22,0x00,0x02]
778 ; X86-AVX1-NEXT: retl ## encoding: [0xc3]
780 ; X86-AVX512-LABEL: insertps_from_load_ins_elt_undef_i32:
781 ; X86-AVX512: ## %bb.0:
782 ; X86-AVX512-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
783 ; X86-AVX512-NEXT: vpinsrd $2, (%eax), %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x22,0x00,0x02]
784 ; X86-AVX512-NEXT: retl ## encoding: [0xc3]
786 ; X64-SSE-LABEL: insertps_from_load_ins_elt_undef_i32:
788 ; X64-SSE-NEXT: pinsrd $2, (%rdi), %xmm0 ## encoding: [0x66,0x0f,0x3a,0x22,0x07,0x02]
789 ; X64-SSE-NEXT: retq ## encoding: [0xc3]
791 ; X64-AVX1-LABEL: insertps_from_load_ins_elt_undef_i32:
792 ; X64-AVX1: ## %bb.0:
793 ; X64-AVX1-NEXT: vpinsrd $2, (%rdi), %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x22,0x07,0x02]
794 ; X64-AVX1-NEXT: retq ## encoding: [0xc3]
796 ; X64-AVX512-LABEL: insertps_from_load_ins_elt_undef_i32:
797 ; X64-AVX512: ## %bb.0:
798 ; X64-AVX512-NEXT: vpinsrd $2, (%rdi), %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x22,0x07,0x02]
799 ; X64-AVX512-NEXT: retq ## encoding: [0xc3]
800 %1 = load i32, i32* %b, align 4
801 %2 = insertelement <4 x i32> undef, i32 %1, i32 0
802 %result = shufflevector <4 x i32> %a, <4 x i32> %2, <4 x i32> <i32 0, i32 1, i32 4, i32 3>
803 ret <4 x i32> %result
806 ;;;;;; Shuffles optimizable with a single insertps or blend instruction
807 define <4 x float> @shuf_XYZ0(<4 x float> %x, <4 x float> %a) {
808 ; SSE-LABEL: shuf_XYZ0:
810 ; SSE-NEXT: xorps %xmm1, %xmm1 ## encoding: [0x0f,0x57,0xc9]
811 ; SSE-NEXT: blendps $8, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x0c,0xc1,0x08]
812 ; SSE-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[3]
813 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
815 ; AVX1-LABEL: shuf_XYZ0:
817 ; AVX1-NEXT: vxorps %xmm1, %xmm1, %xmm1 ## encoding: [0xc5,0xf0,0x57,0xc9]
818 ; AVX1-NEXT: vblendps $8, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x0c,0xc1,0x08]
819 ; AVX1-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[3]
820 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
822 ; AVX512-LABEL: shuf_XYZ0:
824 ; AVX512-NEXT: vxorps %xmm1, %xmm1, %xmm1 ## EVEX TO VEX Compression encoding: [0xc5,0xf0,0x57,0xc9]
825 ; AVX512-NEXT: vblendps $8, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x0c,0xc1,0x08]
826 ; AVX512-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[3]
827 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
828 %vecext = extractelement <4 x float> %x, i32 0
829 %vecinit = insertelement <4 x float> undef, float %vecext, i32 0
830 %vecext1 = extractelement <4 x float> %x, i32 1
831 %vecinit2 = insertelement <4 x float> %vecinit, float %vecext1, i32 1
832 %vecext3 = extractelement <4 x float> %x, i32 2
833 %vecinit4 = insertelement <4 x float> %vecinit2, float %vecext3, i32 2
834 %vecinit5 = insertelement <4 x float> %vecinit4, float 0.0, i32 3
835 ret <4 x float> %vecinit5
838 define <4 x float> @shuf_XY00(<4 x float> %x, <4 x float> %a) {
839 ; SSE-LABEL: shuf_XY00:
841 ; SSE-NEXT: movq %xmm0, %xmm0 ## encoding: [0xf3,0x0f,0x7e,0xc0]
842 ; SSE-NEXT: ## xmm0 = xmm0[0],zero
843 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
845 ; AVX1-LABEL: shuf_XY00:
847 ; AVX1-NEXT: vmovq %xmm0, %xmm0 ## encoding: [0xc5,0xfa,0x7e,0xc0]
848 ; AVX1-NEXT: ## xmm0 = xmm0[0],zero
849 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
851 ; AVX512-LABEL: shuf_XY00:
853 ; AVX512-NEXT: vmovq %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc5,0xfa,0x7e,0xc0]
854 ; AVX512-NEXT: ## xmm0 = xmm0[0],zero
855 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
856 %vecext = extractelement <4 x float> %x, i32 0
857 %vecinit = insertelement <4 x float> undef, float %vecext, i32 0
858 %vecext1 = extractelement <4 x float> %x, i32 1
859 %vecinit2 = insertelement <4 x float> %vecinit, float %vecext1, i32 1
860 %vecinit3 = insertelement <4 x float> %vecinit2, float 0.0, i32 2
861 %vecinit4 = insertelement <4 x float> %vecinit3, float 0.0, i32 3
862 ret <4 x float> %vecinit4
865 define <4 x float> @shuf_XYY0(<4 x float> %x, <4 x float> %a) {
866 ; SSE-LABEL: shuf_XYY0:
868 ; SSE-NEXT: insertps $104, %xmm0, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x21,0xc0,0x68]
869 ; SSE-NEXT: ## xmm0 = xmm0[0,1,1],zero
870 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
872 ; AVX1-LABEL: shuf_XYY0:
874 ; AVX1-NEXT: vinsertps $104, %xmm0, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x21,0xc0,0x68]
875 ; AVX1-NEXT: ## xmm0 = xmm0[0,1,1],zero
876 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
878 ; AVX512-LABEL: shuf_XYY0:
880 ; AVX512-NEXT: vinsertps $104, %xmm0, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x21,0xc0,0x68]
881 ; AVX512-NEXT: ## xmm0 = xmm0[0,1,1],zero
882 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
883 %vecext = extractelement <4 x float> %x, i32 0
884 %vecinit = insertelement <4 x float> undef, float %vecext, i32 0
885 %vecext1 = extractelement <4 x float> %x, i32 1
886 %vecinit2 = insertelement <4 x float> %vecinit, float %vecext1, i32 1
887 %vecinit4 = insertelement <4 x float> %vecinit2, float %vecext1, i32 2
888 %vecinit5 = insertelement <4 x float> %vecinit4, float 0.0, i32 3
889 ret <4 x float> %vecinit5
892 define <4 x float> @shuf_XYW0(<4 x float> %x, <4 x float> %a) {
893 ; SSE-LABEL: shuf_XYW0:
895 ; SSE-NEXT: insertps $232, %xmm0, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x21,0xc0,0xe8]
896 ; SSE-NEXT: ## xmm0 = xmm0[0,1,3],zero
897 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
899 ; AVX1-LABEL: shuf_XYW0:
901 ; AVX1-NEXT: vinsertps $232, %xmm0, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x21,0xc0,0xe8]
902 ; AVX1-NEXT: ## xmm0 = xmm0[0,1,3],zero
903 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
905 ; AVX512-LABEL: shuf_XYW0:
907 ; AVX512-NEXT: vinsertps $232, %xmm0, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x21,0xc0,0xe8]
908 ; AVX512-NEXT: ## xmm0 = xmm0[0,1,3],zero
909 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
910 %vecext = extractelement <4 x float> %x, i32 0
911 %vecinit = insertelement <4 x float> undef, float %vecext, i32 0
912 %vecext1 = extractelement <4 x float> %x, i32 1
913 %vecinit2 = insertelement <4 x float> %vecinit, float %vecext1, i32 1
914 %vecext2 = extractelement <4 x float> %x, i32 3
915 %vecinit3 = insertelement <4 x float> %vecinit2, float %vecext2, i32 2
916 %vecinit4 = insertelement <4 x float> %vecinit3, float 0.0, i32 3
917 ret <4 x float> %vecinit4
920 define <4 x float> @shuf_W00W(<4 x float> %x, <4 x float> %a) {
921 ; SSE-LABEL: shuf_W00W:
923 ; SSE-NEXT: insertps $198, %xmm0, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x21,0xc0,0xc6]
924 ; SSE-NEXT: ## xmm0 = xmm0[3],zero,zero,xmm0[3]
925 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
927 ; AVX1-LABEL: shuf_W00W:
929 ; AVX1-NEXT: vinsertps $198, %xmm0, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x21,0xc0,0xc6]
930 ; AVX1-NEXT: ## xmm0 = xmm0[3],zero,zero,xmm0[3]
931 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
933 ; AVX512-LABEL: shuf_W00W:
935 ; AVX512-NEXT: vinsertps $198, %xmm0, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x21,0xc0,0xc6]
936 ; AVX512-NEXT: ## xmm0 = xmm0[3],zero,zero,xmm0[3]
937 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
938 %vecext = extractelement <4 x float> %x, i32 3
939 %vecinit = insertelement <4 x float> undef, float %vecext, i32 0
940 %vecinit2 = insertelement <4 x float> %vecinit, float 0.0, i32 1
941 %vecinit3 = insertelement <4 x float> %vecinit2, float 0.0, i32 2
942 %vecinit4 = insertelement <4 x float> %vecinit3, float %vecext, i32 3
943 ret <4 x float> %vecinit4
946 define <4 x float> @shuf_X00A(<4 x float> %x, <4 x float> %a) {
947 ; SSE-LABEL: shuf_X00A:
949 ; SSE-NEXT: insertps $54, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x21,0xc1,0x36]
950 ; SSE-NEXT: ## xmm0 = xmm0[0],zero,zero,xmm1[0]
951 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
953 ; AVX1-LABEL: shuf_X00A:
955 ; AVX1-NEXT: vinsertps $54, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x21,0xc1,0x36]
956 ; AVX1-NEXT: ## xmm0 = xmm0[0],zero,zero,xmm1[0]
957 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
959 ; AVX512-LABEL: shuf_X00A:
961 ; AVX512-NEXT: vinsertps $54, %xmm1, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x21,0xc1,0x36]
962 ; AVX512-NEXT: ## xmm0 = xmm0[0],zero,zero,xmm1[0]
963 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
964 %vecext = extractelement <4 x float> %x, i32 0
965 %vecinit = insertelement <4 x float> undef, float %vecext, i32 0
966 %vecinit1 = insertelement <4 x float> %vecinit, float 0.0, i32 1
967 %vecinit2 = insertelement <4 x float> %vecinit1, float 0.0, i32 2
968 %vecinit4 = shufflevector <4 x float> %vecinit2, <4 x float> %a, <4 x i32> <i32 0, i32 1, i32 2, i32 4>
969 ret <4 x float> %vecinit4
972 define <4 x float> @shuf_X00X(<4 x float> %x, <4 x float> %a) {
973 ; SSE-LABEL: shuf_X00X:
975 ; SSE-NEXT: insertps $54, %xmm0, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x21,0xc0,0x36]
976 ; SSE-NEXT: ## xmm0 = xmm0[0],zero,zero,xmm0[0]
977 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
979 ; AVX1-LABEL: shuf_X00X:
981 ; AVX1-NEXT: vinsertps $54, %xmm0, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x21,0xc0,0x36]
982 ; AVX1-NEXT: ## xmm0 = xmm0[0],zero,zero,xmm0[0]
983 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
985 ; AVX512-LABEL: shuf_X00X:
987 ; AVX512-NEXT: vinsertps $54, %xmm0, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x21,0xc0,0x36]
988 ; AVX512-NEXT: ## xmm0 = xmm0[0],zero,zero,xmm0[0]
989 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
990 %vecext = extractelement <4 x float> %x, i32 0
991 %vecinit = insertelement <4 x float> undef, float %vecext, i32 0
992 %vecinit1 = insertelement <4 x float> %vecinit, float 0.0, i32 1
993 %vecinit2 = insertelement <4 x float> %vecinit1, float 0.0, i32 2
994 %vecinit4 = shufflevector <4 x float> %vecinit2, <4 x float> %x, <4 x i32> <i32 0, i32 1, i32 2, i32 4>
995 ret <4 x float> %vecinit4
998 define <4 x float> @shuf_X0YC(<4 x float> %x, <4 x float> %a) {
999 ; SSE-LABEL: shuf_X0YC:
1001 ; SSE-NEXT: xorps %xmm2, %xmm2 ## encoding: [0x0f,0x57,0xd2]
1002 ; SSE-NEXT: unpcklps %xmm2, %xmm0 ## encoding: [0x0f,0x14,0xc2]
1003 ; SSE-NEXT: ## xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
1004 ; SSE-NEXT: insertps $176, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x21,0xc1,0xb0]
1005 ; SSE-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[2]
1006 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1008 ; AVX1-LABEL: shuf_X0YC:
1010 ; AVX1-NEXT: vxorps %xmm2, %xmm2, %xmm2 ## encoding: [0xc5,0xe8,0x57,0xd2]
1011 ; AVX1-NEXT: vunpcklps %xmm2, %xmm0, %xmm0 ## encoding: [0xc5,0xf8,0x14,0xc2]
1012 ; AVX1-NEXT: ## xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
1013 ; AVX1-NEXT: vinsertps $176, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x21,0xc1,0xb0]
1014 ; AVX1-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[2]
1015 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1017 ; AVX512-LABEL: shuf_X0YC:
1019 ; AVX512-NEXT: vxorps %xmm2, %xmm2, %xmm2 ## EVEX TO VEX Compression encoding: [0xc5,0xe8,0x57,0xd2]
1020 ; AVX512-NEXT: vunpcklps %xmm2, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc5,0xf8,0x14,0xc2]
1021 ; AVX512-NEXT: ## xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
1022 ; AVX512-NEXT: vinsertps $176, %xmm1, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x21,0xc1,0xb0]
1023 ; AVX512-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[2]
1024 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1025 %vecext = extractelement <4 x float> %x, i32 0
1026 %vecinit = insertelement <4 x float> undef, float %vecext, i32 0
1027 %vecinit1 = insertelement <4 x float> %vecinit, float 0.0, i32 1
1028 %vecinit3 = shufflevector <4 x float> %vecinit1, <4 x float> %x, <4 x i32> <i32 0, i32 1, i32 5, i32 undef>
1029 %vecinit5 = shufflevector <4 x float> %vecinit3, <4 x float> %a, <4 x i32> <i32 0, i32 1, i32 2, i32 6>
1030 ret <4 x float> %vecinit5
1033 define <4 x i32> @i32_shuf_XYZ0(<4 x i32> %x, <4 x i32> %a) {
1034 ; SSE-LABEL: i32_shuf_XYZ0:
1036 ; SSE-NEXT: xorps %xmm1, %xmm1 ## encoding: [0x0f,0x57,0xc9]
1037 ; SSE-NEXT: blendps $8, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x0c,0xc1,0x08]
1038 ; SSE-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[3]
1039 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1041 ; AVX1-LABEL: i32_shuf_XYZ0:
1043 ; AVX1-NEXT: vxorps %xmm1, %xmm1, %xmm1 ## encoding: [0xc5,0xf0,0x57,0xc9]
1044 ; AVX1-NEXT: vblendps $8, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x0c,0xc1,0x08]
1045 ; AVX1-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[3]
1046 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1048 ; AVX512-LABEL: i32_shuf_XYZ0:
1050 ; AVX512-NEXT: vxorps %xmm1, %xmm1, %xmm1 ## EVEX TO VEX Compression encoding: [0xc5,0xf0,0x57,0xc9]
1051 ; AVX512-NEXT: vblendps $8, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x0c,0xc1,0x08]
1052 ; AVX512-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[3]
1053 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1054 %vecext = extractelement <4 x i32> %x, i32 0
1055 %vecinit = insertelement <4 x i32> undef, i32 %vecext, i32 0
1056 %vecext1 = extractelement <4 x i32> %x, i32 1
1057 %vecinit2 = insertelement <4 x i32> %vecinit, i32 %vecext1, i32 1
1058 %vecext3 = extractelement <4 x i32> %x, i32 2
1059 %vecinit4 = insertelement <4 x i32> %vecinit2, i32 %vecext3, i32 2
1060 %vecinit5 = insertelement <4 x i32> %vecinit4, i32 0, i32 3
1061 ret <4 x i32> %vecinit5
1064 define <4 x i32> @i32_shuf_XY00(<4 x i32> %x, <4 x i32> %a) {
1065 ; SSE-LABEL: i32_shuf_XY00:
1067 ; SSE-NEXT: movq %xmm0, %xmm0 ## encoding: [0xf3,0x0f,0x7e,0xc0]
1068 ; SSE-NEXT: ## xmm0 = xmm0[0],zero
1069 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1071 ; AVX1-LABEL: i32_shuf_XY00:
1073 ; AVX1-NEXT: vmovq %xmm0, %xmm0 ## encoding: [0xc5,0xfa,0x7e,0xc0]
1074 ; AVX1-NEXT: ## xmm0 = xmm0[0],zero
1075 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1077 ; AVX512-LABEL: i32_shuf_XY00:
1079 ; AVX512-NEXT: vmovq %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc5,0xfa,0x7e,0xc0]
1080 ; AVX512-NEXT: ## xmm0 = xmm0[0],zero
1081 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1082 %vecext = extractelement <4 x i32> %x, i32 0
1083 %vecinit = insertelement <4 x i32> undef, i32 %vecext, i32 0
1084 %vecext1 = extractelement <4 x i32> %x, i32 1
1085 %vecinit2 = insertelement <4 x i32> %vecinit, i32 %vecext1, i32 1
1086 %vecinit3 = insertelement <4 x i32> %vecinit2, i32 0, i32 2
1087 %vecinit4 = insertelement <4 x i32> %vecinit3, i32 0, i32 3
1088 ret <4 x i32> %vecinit4
1091 define <4 x i32> @i32_shuf_XYY0(<4 x i32> %x, <4 x i32> %a) {
1092 ; SSE-LABEL: i32_shuf_XYY0:
1094 ; SSE-NEXT: pshufd $212, %xmm0, %xmm1 ## encoding: [0x66,0x0f,0x70,0xc8,0xd4]
1095 ; SSE-NEXT: ## xmm1 = xmm0[0,1,1,3]
1096 ; SSE-NEXT: pxor %xmm0, %xmm0 ## encoding: [0x66,0x0f,0xef,0xc0]
1097 ; SSE-NEXT: pblendw $63, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x0e,0xc1,0x3f]
1098 ; SSE-NEXT: ## xmm0 = xmm1[0,1,2,3,4,5],xmm0[6,7]
1099 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1101 ; AVX1-LABEL: i32_shuf_XYY0:
1103 ; AVX1-NEXT: vpermilps $212, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x04,0xc0,0xd4]
1104 ; AVX1-NEXT: ## xmm0 = xmm0[0,1,1,3]
1105 ; AVX1-NEXT: vxorps %xmm1, %xmm1, %xmm1 ## encoding: [0xc5,0xf0,0x57,0xc9]
1106 ; AVX1-NEXT: vblendps $8, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x0c,0xc1,0x08]
1107 ; AVX1-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[3]
1108 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1110 ; AVX512-LABEL: i32_shuf_XYY0:
1112 ; AVX512-NEXT: vpermilps $212, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x04,0xc0,0xd4]
1113 ; AVX512-NEXT: ## xmm0 = xmm0[0,1,1,3]
1114 ; AVX512-NEXT: vxorps %xmm1, %xmm1, %xmm1 ## EVEX TO VEX Compression encoding: [0xc5,0xf0,0x57,0xc9]
1115 ; AVX512-NEXT: vblendps $8, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x0c,0xc1,0x08]
1116 ; AVX512-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[3]
1117 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1118 %vecext = extractelement <4 x i32> %x, i32 0
1119 %vecinit = insertelement <4 x i32> undef, i32 %vecext, i32 0
1120 %vecext1 = extractelement <4 x i32> %x, i32 1
1121 %vecinit2 = insertelement <4 x i32> %vecinit, i32 %vecext1, i32 1
1122 %vecinit4 = insertelement <4 x i32> %vecinit2, i32 %vecext1, i32 2
1123 %vecinit5 = insertelement <4 x i32> %vecinit4, i32 0, i32 3
1124 ret <4 x i32> %vecinit5
1127 define <4 x i32> @i32_shuf_XYW0(<4 x i32> %x, <4 x i32> %a) {
1128 ; SSE-LABEL: i32_shuf_XYW0:
1130 ; SSE-NEXT: pshufd $244, %xmm0, %xmm1 ## encoding: [0x66,0x0f,0x70,0xc8,0xf4]
1131 ; SSE-NEXT: ## xmm1 = xmm0[0,1,3,3]
1132 ; SSE-NEXT: pxor %xmm0, %xmm0 ## encoding: [0x66,0x0f,0xef,0xc0]
1133 ; SSE-NEXT: pblendw $63, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x0e,0xc1,0x3f]
1134 ; SSE-NEXT: ## xmm0 = xmm1[0,1,2,3,4,5],xmm0[6,7]
1135 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1137 ; AVX1-LABEL: i32_shuf_XYW0:
1139 ; AVX1-NEXT: vpermilps $244, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x04,0xc0,0xf4]
1140 ; AVX1-NEXT: ## xmm0 = xmm0[0,1,3,3]
1141 ; AVX1-NEXT: vxorps %xmm1, %xmm1, %xmm1 ## encoding: [0xc5,0xf0,0x57,0xc9]
1142 ; AVX1-NEXT: vblendps $8, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x0c,0xc1,0x08]
1143 ; AVX1-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[3]
1144 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1146 ; AVX512-LABEL: i32_shuf_XYW0:
1148 ; AVX512-NEXT: vpermilps $244, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x04,0xc0,0xf4]
1149 ; AVX512-NEXT: ## xmm0 = xmm0[0,1,3,3]
1150 ; AVX512-NEXT: vxorps %xmm1, %xmm1, %xmm1 ## EVEX TO VEX Compression encoding: [0xc5,0xf0,0x57,0xc9]
1151 ; AVX512-NEXT: vblendps $8, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x0c,0xc1,0x08]
1152 ; AVX512-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[3]
1153 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1154 %vecext = extractelement <4 x i32> %x, i32 0
1155 %vecinit = insertelement <4 x i32> undef, i32 %vecext, i32 0
1156 %vecext1 = extractelement <4 x i32> %x, i32 1
1157 %vecinit2 = insertelement <4 x i32> %vecinit, i32 %vecext1, i32 1
1158 %vecext2 = extractelement <4 x i32> %x, i32 3
1159 %vecinit3 = insertelement <4 x i32> %vecinit2, i32 %vecext2, i32 2
1160 %vecinit4 = insertelement <4 x i32> %vecinit3, i32 0, i32 3
1161 ret <4 x i32> %vecinit4
1164 define <4 x i32> @i32_shuf_W00W(<4 x i32> %x, <4 x i32> %a) {
1165 ; SSE-LABEL: i32_shuf_W00W:
1167 ; SSE-NEXT: pshufd $231, %xmm0, %xmm1 ## encoding: [0x66,0x0f,0x70,0xc8,0xe7]
1168 ; SSE-NEXT: ## xmm1 = xmm0[3,1,2,3]
1169 ; SSE-NEXT: pxor %xmm0, %xmm0 ## encoding: [0x66,0x0f,0xef,0xc0]
1170 ; SSE-NEXT: pblendw $195, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x0e,0xc1,0xc3]
1171 ; SSE-NEXT: ## xmm0 = xmm1[0,1],xmm0[2,3,4,5],xmm1[6,7]
1172 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1174 ; AVX1-LABEL: i32_shuf_W00W:
1176 ; AVX1-NEXT: vpermilps $231, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x04,0xc0,0xe7]
1177 ; AVX1-NEXT: ## xmm0 = xmm0[3,1,2,3]
1178 ; AVX1-NEXT: vxorps %xmm1, %xmm1, %xmm1 ## encoding: [0xc5,0xf0,0x57,0xc9]
1179 ; AVX1-NEXT: vblendps $6, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x0c,0xc1,0x06]
1180 ; AVX1-NEXT: ## xmm0 = xmm0[0],xmm1[1,2],xmm0[3]
1181 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1183 ; AVX512-LABEL: i32_shuf_W00W:
1185 ; AVX512-NEXT: vpermilps $231, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x04,0xc0,0xe7]
1186 ; AVX512-NEXT: ## xmm0 = xmm0[3,1,2,3]
1187 ; AVX512-NEXT: vxorps %xmm1, %xmm1, %xmm1 ## EVEX TO VEX Compression encoding: [0xc5,0xf0,0x57,0xc9]
1188 ; AVX512-NEXT: vblendps $6, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x0c,0xc1,0x06]
1189 ; AVX512-NEXT: ## xmm0 = xmm0[0],xmm1[1,2],xmm0[3]
1190 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1191 %vecext = extractelement <4 x i32> %x, i32 3
1192 %vecinit = insertelement <4 x i32> undef, i32 %vecext, i32 0
1193 %vecinit2 = insertelement <4 x i32> %vecinit, i32 0, i32 1
1194 %vecinit3 = insertelement <4 x i32> %vecinit2, i32 0, i32 2
1195 %vecinit4 = insertelement <4 x i32> %vecinit3, i32 %vecext, i32 3
1196 ret <4 x i32> %vecinit4
1199 define <4 x i32> @i32_shuf_X00A(<4 x i32> %x, <4 x i32> %a) {
1200 ; SSE-LABEL: i32_shuf_X00A:
1202 ; SSE-NEXT: pxor %xmm2, %xmm2 ## encoding: [0x66,0x0f,0xef,0xd2]
1203 ; SSE-NEXT: pblendw $252, %xmm2, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x0e,0xc2,0xfc]
1204 ; SSE-NEXT: ## xmm0 = xmm0[0,1],xmm2[2,3,4,5,6,7]
1205 ; SSE-NEXT: pshufd $36, %xmm1, %xmm1 ## encoding: [0x66,0x0f,0x70,0xc9,0x24]
1206 ; SSE-NEXT: ## xmm1 = xmm1[0,1,2,0]
1207 ; SSE-NEXT: pblendw $192, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x0e,0xc1,0xc0]
1208 ; SSE-NEXT: ## xmm0 = xmm0[0,1,2,3,4,5],xmm1[6,7]
1209 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1211 ; AVX1-LABEL: i32_shuf_X00A:
1213 ; AVX1-NEXT: vxorps %xmm2, %xmm2, %xmm2 ## encoding: [0xc5,0xe8,0x57,0xd2]
1214 ; AVX1-NEXT: vblendps $1, %xmm0, %xmm2, %xmm0 ## encoding: [0xc4,0xe3,0x69,0x0c,0xc0,0x01]
1215 ; AVX1-NEXT: ## xmm0 = xmm0[0],xmm2[1,2,3]
1216 ; AVX1-NEXT: vpermilps $36, %xmm1, %xmm1 ## encoding: [0xc4,0xe3,0x79,0x04,0xc9,0x24]
1217 ; AVX1-NEXT: ## xmm1 = xmm1[0,1,2,0]
1218 ; AVX1-NEXT: vblendps $8, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x0c,0xc1,0x08]
1219 ; AVX1-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[3]
1220 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1222 ; AVX512-LABEL: i32_shuf_X00A:
1224 ; AVX512-NEXT: vxorps %xmm2, %xmm2, %xmm2 ## encoding: [0xc5,0xe8,0x57,0xd2]
1225 ; AVX512-NEXT: vblendps $1, %xmm0, %xmm2, %xmm0 ## encoding: [0xc4,0xe3,0x69,0x0c,0xc0,0x01]
1226 ; AVX512-NEXT: ## xmm0 = xmm0[0],xmm2[1,2,3]
1227 ; AVX512-NEXT: vbroadcastss %xmm1, %xmm1 ## EVEX TO VEX Compression encoding: [0xc4,0xe2,0x79,0x18,0xc9]
1228 ; AVX512-NEXT: vblendps $8, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x0c,0xc1,0x08]
1229 ; AVX512-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[3]
1230 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1231 %vecext = extractelement <4 x i32> %x, i32 0
1232 %vecinit = insertelement <4 x i32> undef, i32 %vecext, i32 0
1233 %vecinit1 = insertelement <4 x i32> %vecinit, i32 0, i32 1
1234 %vecinit2 = insertelement <4 x i32> %vecinit1, i32 0, i32 2
1235 %vecinit4 = shufflevector <4 x i32> %vecinit2, <4 x i32> %a, <4 x i32> <i32 0, i32 1, i32 2, i32 4>
1236 ret <4 x i32> %vecinit4
1239 define <4 x i32> @i32_shuf_X00X(<4 x i32> %x, <4 x i32> %a) {
1240 ; SSE-LABEL: i32_shuf_X00X:
1242 ; SSE-NEXT: pxor %xmm1, %xmm1 ## encoding: [0x66,0x0f,0xef,0xc9]
1243 ; SSE-NEXT: pshufd $36, %xmm0, %xmm0 ## encoding: [0x66,0x0f,0x70,0xc0,0x24]
1244 ; SSE-NEXT: ## xmm0 = xmm0[0,1,2,0]
1245 ; SSE-NEXT: pblendw $60, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x0e,0xc1,0x3c]
1246 ; SSE-NEXT: ## xmm0 = xmm0[0,1],xmm1[2,3,4,5],xmm0[6,7]
1247 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1249 ; AVX1-LABEL: i32_shuf_X00X:
1251 ; AVX1-NEXT: vxorps %xmm1, %xmm1, %xmm1 ## encoding: [0xc5,0xf0,0x57,0xc9]
1252 ; AVX1-NEXT: vpermilps $36, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x04,0xc0,0x24]
1253 ; AVX1-NEXT: ## xmm0 = xmm0[0,1,2,0]
1254 ; AVX1-NEXT: vblendps $6, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x0c,0xc1,0x06]
1255 ; AVX1-NEXT: ## xmm0 = xmm0[0],xmm1[1,2],xmm0[3]
1256 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1258 ; AVX512-LABEL: i32_shuf_X00X:
1260 ; AVX512-NEXT: vxorps %xmm1, %xmm1, %xmm1 ## EVEX TO VEX Compression encoding: [0xc5,0xf0,0x57,0xc9]
1261 ; AVX512-NEXT: vbroadcastss %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe2,0x79,0x18,0xc0]
1262 ; AVX512-NEXT: vblendps $6, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x0c,0xc1,0x06]
1263 ; AVX512-NEXT: ## xmm0 = xmm0[0],xmm1[1,2],xmm0[3]
1264 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1265 %vecext = extractelement <4 x i32> %x, i32 0
1266 %vecinit = insertelement <4 x i32> undef, i32 %vecext, i32 0
1267 %vecinit1 = insertelement <4 x i32> %vecinit, i32 0, i32 1
1268 %vecinit2 = insertelement <4 x i32> %vecinit1, i32 0, i32 2
1269 %vecinit4 = shufflevector <4 x i32> %vecinit2, <4 x i32> %x, <4 x i32> <i32 0, i32 1, i32 2, i32 4>
1270 ret <4 x i32> %vecinit4
1273 define <4 x i32> @i32_shuf_X0YC(<4 x i32> %x, <4 x i32> %a) {
1274 ; SSE-LABEL: i32_shuf_X0YC:
1276 ; SSE-NEXT: pmovzxdq %xmm0, %xmm2 ## encoding: [0x66,0x0f,0x38,0x35,0xd0]
1277 ; SSE-NEXT: ## xmm2 = xmm0[0],zero,xmm0[1],zero
1278 ; SSE-NEXT: pshufd $164, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x70,0xc1,0xa4]
1279 ; SSE-NEXT: ## xmm0 = xmm1[0,1,2,2]
1280 ; SSE-NEXT: pblendw $63, %xmm2, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x0e,0xc2,0x3f]
1281 ; SSE-NEXT: ## xmm0 = xmm2[0,1,2,3,4,5],xmm0[6,7]
1282 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1284 ; AVX1-LABEL: i32_shuf_X0YC:
1286 ; AVX1-NEXT: vpmovzxdq %xmm0, %xmm0 ## encoding: [0xc4,0xe2,0x79,0x35,0xc0]
1287 ; AVX1-NEXT: ## xmm0 = xmm0[0],zero,xmm0[1],zero
1288 ; AVX1-NEXT: vpshufd $164, %xmm1, %xmm1 ## encoding: [0xc5,0xf9,0x70,0xc9,0xa4]
1289 ; AVX1-NEXT: ## xmm1 = xmm1[0,1,2,2]
1290 ; AVX1-NEXT: vpblendw $192, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x0e,0xc1,0xc0]
1291 ; AVX1-NEXT: ## xmm0 = xmm0[0,1,2,3,4,5],xmm1[6,7]
1292 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1294 ; AVX512-LABEL: i32_shuf_X0YC:
1296 ; AVX512-NEXT: vpmovzxdq %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe2,0x79,0x35,0xc0]
1297 ; AVX512-NEXT: ## xmm0 = xmm0[0],zero,xmm0[1],zero
1298 ; AVX512-NEXT: vpshufd $164, %xmm1, %xmm1 ## EVEX TO VEX Compression encoding: [0xc5,0xf9,0x70,0xc9,0xa4]
1299 ; AVX512-NEXT: ## xmm1 = xmm1[0,1,2,2]
1300 ; AVX512-NEXT: vpblendd $8, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x02,0xc1,0x08]
1301 ; AVX512-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[3]
1302 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1303 %vecext = extractelement <4 x i32> %x, i32 0
1304 %vecinit = insertelement <4 x i32> undef, i32 %vecext, i32 0
1305 %vecinit1 = insertelement <4 x i32> %vecinit, i32 0, i32 1
1306 %vecinit3 = shufflevector <4 x i32> %vecinit1, <4 x i32> %x, <4 x i32> <i32 0, i32 1, i32 5, i32 undef>
1307 %vecinit5 = shufflevector <4 x i32> %vecinit3, <4 x i32> %a, <4 x i32> <i32 0, i32 1, i32 2, i32 6>
1308 ret <4 x i32> %vecinit5
1311 ;; Test for a bug in the first implementation of LowerBuildVectorv4X86
1312 define < 4 x float> @test_insertps_no_undef(<4 x float> %x) {
1313 ; SSE-LABEL: test_insertps_no_undef:
1315 ; SSE-NEXT: xorps %xmm1, %xmm1 ## encoding: [0x0f,0x57,0xc9]
1316 ; SSE-NEXT: blendps $7, %xmm0, %xmm1 ## encoding: [0x66,0x0f,0x3a,0x0c,0xc8,0x07]
1317 ; SSE-NEXT: ## xmm1 = xmm0[0,1,2],xmm1[3]
1318 ; SSE-NEXT: maxps %xmm1, %xmm0 ## encoding: [0x0f,0x5f,0xc1]
1319 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1321 ; AVX1-LABEL: test_insertps_no_undef:
1323 ; AVX1-NEXT: vxorps %xmm1, %xmm1, %xmm1 ## encoding: [0xc5,0xf0,0x57,0xc9]
1324 ; AVX1-NEXT: vblendps $8, %xmm1, %xmm0, %xmm1 ## encoding: [0xc4,0xe3,0x79,0x0c,0xc9,0x08]
1325 ; AVX1-NEXT: ## xmm1 = xmm0[0,1,2],xmm1[3]
1326 ; AVX1-NEXT: vmaxps %xmm1, %xmm0, %xmm0 ## encoding: [0xc5,0xf8,0x5f,0xc1]
1327 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1329 ; AVX512-LABEL: test_insertps_no_undef:
1331 ; AVX512-NEXT: vxorps %xmm1, %xmm1, %xmm1 ## EVEX TO VEX Compression encoding: [0xc5,0xf0,0x57,0xc9]
1332 ; AVX512-NEXT: vblendps $8, %xmm1, %xmm0, %xmm1 ## encoding: [0xc4,0xe3,0x79,0x0c,0xc9,0x08]
1333 ; AVX512-NEXT: ## xmm1 = xmm0[0,1,2],xmm1[3]
1334 ; AVX512-NEXT: vmaxps %xmm1, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc5,0xf8,0x5f,0xc1]
1335 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1336 %vecext = extractelement <4 x float> %x, i32 0
1337 %vecinit = insertelement <4 x float> undef, float %vecext, i32 0
1338 %vecext1 = extractelement <4 x float> %x, i32 1
1339 %vecinit2 = insertelement <4 x float> %vecinit, float %vecext1, i32 1
1340 %vecext3 = extractelement <4 x float> %x, i32 2
1341 %vecinit4 = insertelement <4 x float> %vecinit2, float %vecext3, i32 2
1342 %vecinit5 = insertelement <4 x float> %vecinit4, float 0.0, i32 3
1343 %mask = fcmp olt <4 x float> %vecinit5, %x
1344 %res = select <4 x i1> %mask, <4 x float> %x, <4 x float>%vecinit5
1345 ret <4 x float> %res
1348 define <8 x i16> @blendvb_fallback(<8 x i1> %mask, <8 x i16> %x, <8 x i16> %y) {
1349 ; SSE-LABEL: blendvb_fallback:
1351 ; SSE-NEXT: psllw $15, %xmm0 ## encoding: [0x66,0x0f,0x71,0xf0,0x0f]
1352 ; SSE-NEXT: psraw $15, %xmm0 ## encoding: [0x66,0x0f,0x71,0xe0,0x0f]
1353 ; SSE-NEXT: pblendvb %xmm0, %xmm1, %xmm2 ## encoding: [0x66,0x0f,0x38,0x10,0xd1]
1354 ; SSE-NEXT: movdqa %xmm2, %xmm0 ## encoding: [0x66,0x0f,0x6f,0xc2]
1355 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1357 ; AVX1-LABEL: blendvb_fallback:
1359 ; AVX1-NEXT: vpsllw $15, %xmm0, %xmm0 ## encoding: [0xc5,0xf9,0x71,0xf0,0x0f]
1360 ; AVX1-NEXT: vpsraw $15, %xmm0, %xmm0 ## encoding: [0xc5,0xf9,0x71,0xe0,0x0f]
1361 ; AVX1-NEXT: vpblendvb %xmm0, %xmm1, %xmm2, %xmm0 ## encoding: [0xc4,0xe3,0x69,0x4c,0xc1,0x00]
1362 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1364 ; AVX512-LABEL: blendvb_fallback:
1366 ; AVX512-NEXT: vpsllw $15, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc5,0xf9,0x71,0xf0,0x0f]
1367 ; AVX512-NEXT: vpmovw2m %xmm0, %k1 ## encoding: [0x62,0xf2,0xfe,0x08,0x29,0xc8]
1368 ; AVX512-NEXT: vpblendmw %xmm1, %xmm2, %xmm0 {%k1} ## encoding: [0x62,0xf2,0xed,0x09,0x66,0xc1]
1369 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1370 %ret = select <8 x i1> %mask, <8 x i16> %x, <8 x i16> %y
1374 ; On X86, account for the argument's move to registers
1375 define <4 x float> @insertps_from_vector_load(<4 x float> %a, <4 x float>* nocapture readonly %pb) {
1376 ; X86-SSE-LABEL: insertps_from_vector_load:
1377 ; X86-SSE: ## %bb.0:
1378 ; X86-SSE-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
1379 ; X86-SSE-NEXT: movaps (%eax), %xmm1 ## encoding: [0x0f,0x28,0x08]
1380 ; X86-SSE-NEXT: insertps $48, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x21,0xc1,0x30]
1381 ; X86-SSE-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[0]
1382 ; X86-SSE-NEXT: retl ## encoding: [0xc3]
1384 ; X86-AVX1-LABEL: insertps_from_vector_load:
1385 ; X86-AVX1: ## %bb.0:
1386 ; X86-AVX1-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
1387 ; X86-AVX1-NEXT: vmovaps (%eax), %xmm1 ## encoding: [0xc5,0xf8,0x28,0x08]
1388 ; X86-AVX1-NEXT: vinsertps $48, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x21,0xc1,0x30]
1389 ; X86-AVX1-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[0]
1390 ; X86-AVX1-NEXT: retl ## encoding: [0xc3]
1392 ; X86-AVX512-LABEL: insertps_from_vector_load:
1393 ; X86-AVX512: ## %bb.0:
1394 ; X86-AVX512-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
1395 ; X86-AVX512-NEXT: vmovaps (%eax), %xmm1 ## EVEX TO VEX Compression encoding: [0xc5,0xf8,0x28,0x08]
1396 ; X86-AVX512-NEXT: vinsertps $48, %xmm1, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x21,0xc1,0x30]
1397 ; X86-AVX512-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[0]
1398 ; X86-AVX512-NEXT: retl ## encoding: [0xc3]
1400 ; X64-SSE-LABEL: insertps_from_vector_load:
1401 ; X64-SSE: ## %bb.0:
1402 ; X64-SSE-NEXT: movaps (%rdi), %xmm1 ## encoding: [0x0f,0x28,0x0f]
1403 ; X64-SSE-NEXT: insertps $48, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x21,0xc1,0x30]
1404 ; X64-SSE-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[0]
1405 ; X64-SSE-NEXT: retq ## encoding: [0xc3]
1407 ; X64-AVX1-LABEL: insertps_from_vector_load:
1408 ; X64-AVX1: ## %bb.0:
1409 ; X64-AVX1-NEXT: vmovaps (%rdi), %xmm1 ## encoding: [0xc5,0xf8,0x28,0x0f]
1410 ; X64-AVX1-NEXT: vinsertps $48, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x21,0xc1,0x30]
1411 ; X64-AVX1-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[0]
1412 ; X64-AVX1-NEXT: retq ## encoding: [0xc3]
1414 ; X64-AVX512-LABEL: insertps_from_vector_load:
1415 ; X64-AVX512: ## %bb.0:
1416 ; X64-AVX512-NEXT: vmovaps (%rdi), %xmm1 ## EVEX TO VEX Compression encoding: [0xc5,0xf8,0x28,0x0f]
1417 ; X64-AVX512-NEXT: vinsertps $48, %xmm1, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x21,0xc1,0x30]
1418 ; X64-AVX512-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[0]
1419 ; X64-AVX512-NEXT: retq ## encoding: [0xc3]
1420 %1 = load <4 x float>, <4 x float>* %pb, align 16
1421 %2 = tail call <4 x float> @llvm.x86.sse41.insertps(<4 x float> %a, <4 x float> %1, i32 48)
1425 ;; Use a non-zero CountS for insertps
1426 ;; Try to match a bit more of the instr, since we need the load's offset.
1427 define <4 x float> @insertps_from_vector_load_offset(<4 x float> %a, <4 x float>* nocapture readonly %pb) {
1428 ; X86-SSE-LABEL: insertps_from_vector_load_offset:
1429 ; X86-SSE: ## %bb.0:
1430 ; X86-SSE-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
1431 ; X86-SSE-NEXT: movaps (%eax), %xmm1 ## encoding: [0x0f,0x28,0x08]
1432 ; X86-SSE-NEXT: insertps $96, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x21,0xc1,0x60]
1433 ; X86-SSE-NEXT: ## xmm0 = xmm0[0,1],xmm1[1],xmm0[3]
1434 ; X86-SSE-NEXT: retl ## encoding: [0xc3]
1436 ; X86-AVX1-LABEL: insertps_from_vector_load_offset:
1437 ; X86-AVX1: ## %bb.0:
1438 ; X86-AVX1-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
1439 ; X86-AVX1-NEXT: vmovaps (%eax), %xmm1 ## encoding: [0xc5,0xf8,0x28,0x08]
1440 ; X86-AVX1-NEXT: vinsertps $96, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x21,0xc1,0x60]
1441 ; X86-AVX1-NEXT: ## xmm0 = xmm0[0,1],xmm1[1],xmm0[3]
1442 ; X86-AVX1-NEXT: retl ## encoding: [0xc3]
1444 ; X86-AVX512-LABEL: insertps_from_vector_load_offset:
1445 ; X86-AVX512: ## %bb.0:
1446 ; X86-AVX512-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
1447 ; X86-AVX512-NEXT: vmovaps (%eax), %xmm1 ## EVEX TO VEX Compression encoding: [0xc5,0xf8,0x28,0x08]
1448 ; X86-AVX512-NEXT: vinsertps $96, %xmm1, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x21,0xc1,0x60]
1449 ; X86-AVX512-NEXT: ## xmm0 = xmm0[0,1],xmm1[1],xmm0[3]
1450 ; X86-AVX512-NEXT: retl ## encoding: [0xc3]
1452 ; X64-SSE-LABEL: insertps_from_vector_load_offset:
1453 ; X64-SSE: ## %bb.0:
1454 ; X64-SSE-NEXT: movaps (%rdi), %xmm1 ## encoding: [0x0f,0x28,0x0f]
1455 ; X64-SSE-NEXT: insertps $96, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x21,0xc1,0x60]
1456 ; X64-SSE-NEXT: ## xmm0 = xmm0[0,1],xmm1[1],xmm0[3]
1457 ; X64-SSE-NEXT: retq ## encoding: [0xc3]
1459 ; X64-AVX1-LABEL: insertps_from_vector_load_offset:
1460 ; X64-AVX1: ## %bb.0:
1461 ; X64-AVX1-NEXT: vmovaps (%rdi), %xmm1 ## encoding: [0xc5,0xf8,0x28,0x0f]
1462 ; X64-AVX1-NEXT: vinsertps $96, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x21,0xc1,0x60]
1463 ; X64-AVX1-NEXT: ## xmm0 = xmm0[0,1],xmm1[1],xmm0[3]
1464 ; X64-AVX1-NEXT: retq ## encoding: [0xc3]
1466 ; X64-AVX512-LABEL: insertps_from_vector_load_offset:
1467 ; X64-AVX512: ## %bb.0:
1468 ; X64-AVX512-NEXT: vmovaps (%rdi), %xmm1 ## EVEX TO VEX Compression encoding: [0xc5,0xf8,0x28,0x0f]
1469 ; X64-AVX512-NEXT: vinsertps $96, %xmm1, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x21,0xc1,0x60]
1470 ; X64-AVX512-NEXT: ## xmm0 = xmm0[0,1],xmm1[1],xmm0[3]
1471 ; X64-AVX512-NEXT: retq ## encoding: [0xc3]
1472 %1 = load <4 x float>, <4 x float>* %pb, align 16
1473 %2 = tail call <4 x float> @llvm.x86.sse41.insertps(<4 x float> %a, <4 x float> %1, i32 96)
1477 ;; Try to match a bit more of the instr, since we need the load's offset.
1478 define <4 x float> @insertps_from_vector_load_offset_2(<4 x float> %a, <4 x float>* nocapture readonly %pb, i64 %index) {
1479 ; X86-SSE-LABEL: insertps_from_vector_load_offset_2:
1480 ; X86-SSE: ## %bb.0:
1481 ; X86-SSE-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
1482 ; X86-SSE-NEXT: movl {{[0-9]+}}(%esp), %ecx ## encoding: [0x8b,0x4c,0x24,0x08]
1483 ; X86-SSE-NEXT: shll $4, %ecx ## encoding: [0xc1,0xe1,0x04]
1484 ; X86-SSE-NEXT: movaps (%eax,%ecx), %xmm1 ## encoding: [0x0f,0x28,0x0c,0x08]
1485 ; X86-SSE-NEXT: insertps $192, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x21,0xc1,0xc0]
1486 ; X86-SSE-NEXT: ## xmm0 = xmm1[3],xmm0[1,2,3]
1487 ; X86-SSE-NEXT: retl ## encoding: [0xc3]
1489 ; X86-AVX1-LABEL: insertps_from_vector_load_offset_2:
1490 ; X86-AVX1: ## %bb.0:
1491 ; X86-AVX1-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
1492 ; X86-AVX1-NEXT: movl {{[0-9]+}}(%esp), %ecx ## encoding: [0x8b,0x4c,0x24,0x08]
1493 ; X86-AVX1-NEXT: shll $4, %ecx ## encoding: [0xc1,0xe1,0x04]
1494 ; X86-AVX1-NEXT: vmovaps (%eax,%ecx), %xmm1 ## encoding: [0xc5,0xf8,0x28,0x0c,0x08]
1495 ; X86-AVX1-NEXT: vinsertps $192, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x21,0xc1,0xc0]
1496 ; X86-AVX1-NEXT: ## xmm0 = xmm1[3],xmm0[1,2,3]
1497 ; X86-AVX1-NEXT: retl ## encoding: [0xc3]
1499 ; X86-AVX512-LABEL: insertps_from_vector_load_offset_2:
1500 ; X86-AVX512: ## %bb.0:
1501 ; X86-AVX512-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
1502 ; X86-AVX512-NEXT: movl {{[0-9]+}}(%esp), %ecx ## encoding: [0x8b,0x4c,0x24,0x08]
1503 ; X86-AVX512-NEXT: shll $4, %ecx ## encoding: [0xc1,0xe1,0x04]
1504 ; X86-AVX512-NEXT: vmovaps (%eax,%ecx), %xmm1 ## EVEX TO VEX Compression encoding: [0xc5,0xf8,0x28,0x0c,0x08]
1505 ; X86-AVX512-NEXT: vinsertps $192, %xmm1, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x21,0xc1,0xc0]
1506 ; X86-AVX512-NEXT: ## xmm0 = xmm1[3],xmm0[1,2,3]
1507 ; X86-AVX512-NEXT: retl ## encoding: [0xc3]
1509 ; X64-SSE-LABEL: insertps_from_vector_load_offset_2:
1510 ; X64-SSE: ## %bb.0:
1511 ; X64-SSE-NEXT: shlq $4, %rsi ## encoding: [0x48,0xc1,0xe6,0x04]
1512 ; X64-SSE-NEXT: movaps (%rdi,%rsi), %xmm1 ## encoding: [0x0f,0x28,0x0c,0x37]
1513 ; X64-SSE-NEXT: insertps $192, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x21,0xc1,0xc0]
1514 ; X64-SSE-NEXT: ## xmm0 = xmm1[3],xmm0[1,2,3]
1515 ; X64-SSE-NEXT: retq ## encoding: [0xc3]
1517 ; X64-AVX1-LABEL: insertps_from_vector_load_offset_2:
1518 ; X64-AVX1: ## %bb.0:
1519 ; X64-AVX1-NEXT: shlq $4, %rsi ## encoding: [0x48,0xc1,0xe6,0x04]
1520 ; X64-AVX1-NEXT: vmovaps (%rdi,%rsi), %xmm1 ## encoding: [0xc5,0xf8,0x28,0x0c,0x37]
1521 ; X64-AVX1-NEXT: vinsertps $192, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x21,0xc1,0xc0]
1522 ; X64-AVX1-NEXT: ## xmm0 = xmm1[3],xmm0[1,2,3]
1523 ; X64-AVX1-NEXT: retq ## encoding: [0xc3]
1525 ; X64-AVX512-LABEL: insertps_from_vector_load_offset_2:
1526 ; X64-AVX512: ## %bb.0:
1527 ; X64-AVX512-NEXT: shlq $4, %rsi ## encoding: [0x48,0xc1,0xe6,0x04]
1528 ; X64-AVX512-NEXT: vmovaps (%rdi,%rsi), %xmm1 ## EVEX TO VEX Compression encoding: [0xc5,0xf8,0x28,0x0c,0x37]
1529 ; X64-AVX512-NEXT: vinsertps $192, %xmm1, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x21,0xc1,0xc0]
1530 ; X64-AVX512-NEXT: ## xmm0 = xmm1[3],xmm0[1,2,3]
1531 ; X64-AVX512-NEXT: retq ## encoding: [0xc3]
1532 %1 = getelementptr inbounds <4 x float>, <4 x float>* %pb, i64 %index
1533 %2 = load <4 x float>, <4 x float>* %1, align 16
1534 %3 = tail call <4 x float> @llvm.x86.sse41.insertps(<4 x float> %a, <4 x float> %2, i32 192)
1538 define <4 x float> @insertps_from_broadcast_loadf32(<4 x float> %a, float* nocapture readonly %fb, i64 %index) {
1539 ; X86-SSE-LABEL: insertps_from_broadcast_loadf32:
1540 ; X86-SSE: ## %bb.0:
1541 ; X86-SSE-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x08]
1542 ; X86-SSE-NEXT: movl {{[0-9]+}}(%esp), %ecx ## encoding: [0x8b,0x4c,0x24,0x04]
1543 ; X86-SSE-NEXT: insertps $48, (%ecx,%eax,4), %xmm0 ## encoding: [0x66,0x0f,0x3a,0x21,0x04,0x81,0x30]
1544 ; X86-SSE-NEXT: ## xmm0 = xmm0[0,1,2],mem[0]
1545 ; X86-SSE-NEXT: retl ## encoding: [0xc3]
1547 ; X86-AVX1-LABEL: insertps_from_broadcast_loadf32:
1548 ; X86-AVX1: ## %bb.0:
1549 ; X86-AVX1-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x08]
1550 ; X86-AVX1-NEXT: movl {{[0-9]+}}(%esp), %ecx ## encoding: [0x8b,0x4c,0x24,0x04]
1551 ; X86-AVX1-NEXT: vinsertps $48, (%ecx,%eax,4), %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x21,0x04,0x81,0x30]
1552 ; X86-AVX1-NEXT: ## xmm0 = xmm0[0,1,2],mem[0]
1553 ; X86-AVX1-NEXT: retl ## encoding: [0xc3]
1555 ; X86-AVX512-LABEL: insertps_from_broadcast_loadf32:
1556 ; X86-AVX512: ## %bb.0:
1557 ; X86-AVX512-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x08]
1558 ; X86-AVX512-NEXT: movl {{[0-9]+}}(%esp), %ecx ## encoding: [0x8b,0x4c,0x24,0x04]
1559 ; X86-AVX512-NEXT: vbroadcastss (%ecx,%eax,4), %xmm1 ## EVEX TO VEX Compression encoding: [0xc4,0xe2,0x79,0x18,0x0c,0x81]
1560 ; X86-AVX512-NEXT: vinsertps $48, %xmm1, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x21,0xc1,0x30]
1561 ; X86-AVX512-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[0]
1562 ; X86-AVX512-NEXT: retl ## encoding: [0xc3]
1564 ; X64-SSE-LABEL: insertps_from_broadcast_loadf32:
1565 ; X64-SSE: ## %bb.0:
1566 ; X64-SSE-NEXT: insertps $48, (%rdi,%rsi,4), %xmm0 ## encoding: [0x66,0x0f,0x3a,0x21,0x04,0xb7,0x30]
1567 ; X64-SSE-NEXT: ## xmm0 = xmm0[0,1,2],mem[0]
1568 ; X64-SSE-NEXT: retq ## encoding: [0xc3]
1570 ; X64-AVX1-LABEL: insertps_from_broadcast_loadf32:
1571 ; X64-AVX1: ## %bb.0:
1572 ; X64-AVX1-NEXT: vinsertps $48, (%rdi,%rsi,4), %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x21,0x04,0xb7,0x30]
1573 ; X64-AVX1-NEXT: ## xmm0 = xmm0[0,1,2],mem[0]
1574 ; X64-AVX1-NEXT: retq ## encoding: [0xc3]
1576 ; X64-AVX512-LABEL: insertps_from_broadcast_loadf32:
1577 ; X64-AVX512: ## %bb.0:
1578 ; X64-AVX512-NEXT: vbroadcastss (%rdi,%rsi,4), %xmm1 ## EVEX TO VEX Compression encoding: [0xc4,0xe2,0x79,0x18,0x0c,0xb7]
1579 ; X64-AVX512-NEXT: vinsertps $48, %xmm1, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x21,0xc1,0x30]
1580 ; X64-AVX512-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[0]
1581 ; X64-AVX512-NEXT: retq ## encoding: [0xc3]
1582 %1 = getelementptr inbounds float, float* %fb, i64 %index
1583 %2 = load float, float* %1, align 4
1584 %3 = insertelement <4 x float> undef, float %2, i32 0
1585 %4 = insertelement <4 x float> %3, float %2, i32 1
1586 %5 = insertelement <4 x float> %4, float %2, i32 2
1587 %6 = insertelement <4 x float> %5, float %2, i32 3
1588 %7 = tail call <4 x float> @llvm.x86.sse41.insertps(<4 x float> %a, <4 x float> %6, i32 48)
1592 define <4 x float> @insertps_from_broadcast_loadv4f32(<4 x float> %a, <4 x float>* nocapture readonly %b) {
1593 ; X86-SSE-LABEL: insertps_from_broadcast_loadv4f32:
1594 ; X86-SSE: ## %bb.0:
1595 ; X86-SSE-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
1596 ; X86-SSE-NEXT: movups (%eax), %xmm1 ## encoding: [0x0f,0x10,0x08]
1597 ; X86-SSE-NEXT: insertps $48, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x21,0xc1,0x30]
1598 ; X86-SSE-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[0]
1599 ; X86-SSE-NEXT: retl ## encoding: [0xc3]
1601 ; X86-AVX1-LABEL: insertps_from_broadcast_loadv4f32:
1602 ; X86-AVX1: ## %bb.0:
1603 ; X86-AVX1-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
1604 ; X86-AVX1-NEXT: vinsertps $48, (%eax), %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x21,0x00,0x30]
1605 ; X86-AVX1-NEXT: ## xmm0 = xmm0[0,1,2],mem[0]
1606 ; X86-AVX1-NEXT: retl ## encoding: [0xc3]
1608 ; X86-AVX512-LABEL: insertps_from_broadcast_loadv4f32:
1609 ; X86-AVX512: ## %bb.0:
1610 ; X86-AVX512-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
1611 ; X86-AVX512-NEXT: vbroadcastss (%eax), %xmm1 ## EVEX TO VEX Compression encoding: [0xc4,0xe2,0x79,0x18,0x08]
1612 ; X86-AVX512-NEXT: vinsertps $48, %xmm1, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x21,0xc1,0x30]
1613 ; X86-AVX512-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[0]
1614 ; X86-AVX512-NEXT: retl ## encoding: [0xc3]
1616 ; X64-SSE-LABEL: insertps_from_broadcast_loadv4f32:
1617 ; X64-SSE: ## %bb.0:
1618 ; X64-SSE-NEXT: movups (%rdi), %xmm1 ## encoding: [0x0f,0x10,0x0f]
1619 ; X64-SSE-NEXT: insertps $48, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x21,0xc1,0x30]
1620 ; X64-SSE-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[0]
1621 ; X64-SSE-NEXT: retq ## encoding: [0xc3]
1623 ; X64-AVX1-LABEL: insertps_from_broadcast_loadv4f32:
1624 ; X64-AVX1: ## %bb.0:
1625 ; X64-AVX1-NEXT: vinsertps $48, (%rdi), %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x21,0x07,0x30]
1626 ; X64-AVX1-NEXT: ## xmm0 = xmm0[0,1,2],mem[0]
1627 ; X64-AVX1-NEXT: retq ## encoding: [0xc3]
1629 ; X64-AVX512-LABEL: insertps_from_broadcast_loadv4f32:
1630 ; X64-AVX512: ## %bb.0:
1631 ; X64-AVX512-NEXT: vbroadcastss (%rdi), %xmm1 ## EVEX TO VEX Compression encoding: [0xc4,0xe2,0x79,0x18,0x0f]
1632 ; X64-AVX512-NEXT: vinsertps $48, %xmm1, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x21,0xc1,0x30]
1633 ; X64-AVX512-NEXT: ## xmm0 = xmm0[0,1,2],xmm1[0]
1634 ; X64-AVX512-NEXT: retq ## encoding: [0xc3]
1635 %1 = load <4 x float>, <4 x float>* %b, align 4
1636 %2 = extractelement <4 x float> %1, i32 0
1637 %3 = insertelement <4 x float> undef, float %2, i32 0
1638 %4 = insertelement <4 x float> %3, float %2, i32 1
1639 %5 = insertelement <4 x float> %4, float %2, i32 2
1640 %6 = insertelement <4 x float> %5, float %2, i32 3
1641 %7 = tail call <4 x float> @llvm.x86.sse41.insertps(<4 x float> %a, <4 x float> %6, i32 48)
1645 define <4 x float> @insertps_from_broadcast_multiple_use(<4 x float> %a, <4 x float> %b, <4 x float> %c, <4 x float> %d, float* nocapture readonly %fb, i64 %index) {
1646 ; X86-SSE-LABEL: insertps_from_broadcast_multiple_use:
1647 ; X86-SSE: ## %bb.0:
1648 ; X86-SSE-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x08]
1649 ; X86-SSE-NEXT: movl {{[0-9]+}}(%esp), %ecx ## encoding: [0x8b,0x4c,0x24,0x04]
1650 ; X86-SSE-NEXT: movss (%ecx,%eax,4), %xmm4 ## encoding: [0xf3,0x0f,0x10,0x24,0x81]
1651 ; X86-SSE-NEXT: ## xmm4 = mem[0],zero,zero,zero
1652 ; X86-SSE-NEXT: insertps $48, %xmm4, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x21,0xc4,0x30]
1653 ; X86-SSE-NEXT: ## xmm0 = xmm0[0,1,2],xmm4[0]
1654 ; X86-SSE-NEXT: insertps $48, %xmm4, %xmm1 ## encoding: [0x66,0x0f,0x3a,0x21,0xcc,0x30]
1655 ; X86-SSE-NEXT: ## xmm1 = xmm1[0,1,2],xmm4[0]
1656 ; X86-SSE-NEXT: addps %xmm1, %xmm0 ## encoding: [0x0f,0x58,0xc1]
1657 ; X86-SSE-NEXT: insertps $48, %xmm4, %xmm2 ## encoding: [0x66,0x0f,0x3a,0x21,0xd4,0x30]
1658 ; X86-SSE-NEXT: ## xmm2 = xmm2[0,1,2],xmm4[0]
1659 ; X86-SSE-NEXT: insertps $48, %xmm4, %xmm3 ## encoding: [0x66,0x0f,0x3a,0x21,0xdc,0x30]
1660 ; X86-SSE-NEXT: ## xmm3 = xmm3[0,1,2],xmm4[0]
1661 ; X86-SSE-NEXT: addps %xmm2, %xmm3 ## encoding: [0x0f,0x58,0xda]
1662 ; X86-SSE-NEXT: addps %xmm3, %xmm0 ## encoding: [0x0f,0x58,0xc3]
1663 ; X86-SSE-NEXT: retl ## encoding: [0xc3]
1665 ; X86-AVX1-LABEL: insertps_from_broadcast_multiple_use:
1666 ; X86-AVX1: ## %bb.0:
1667 ; X86-AVX1-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x08]
1668 ; X86-AVX1-NEXT: movl {{[0-9]+}}(%esp), %ecx ## encoding: [0x8b,0x4c,0x24,0x04]
1669 ; X86-AVX1-NEXT: vbroadcastss (%ecx,%eax,4), %xmm4 ## encoding: [0xc4,0xe2,0x79,0x18,0x24,0x81]
1670 ; X86-AVX1-NEXT: vinsertps $48, %xmm4, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x21,0xc4,0x30]
1671 ; X86-AVX1-NEXT: ## xmm0 = xmm0[0,1,2],xmm4[0]
1672 ; X86-AVX1-NEXT: vinsertps $48, %xmm4, %xmm1, %xmm1 ## encoding: [0xc4,0xe3,0x71,0x21,0xcc,0x30]
1673 ; X86-AVX1-NEXT: ## xmm1 = xmm1[0,1,2],xmm4[0]
1674 ; X86-AVX1-NEXT: vaddps %xmm1, %xmm0, %xmm0 ## encoding: [0xc5,0xf8,0x58,0xc1]
1675 ; X86-AVX1-NEXT: vinsertps $48, %xmm4, %xmm2, %xmm1 ## encoding: [0xc4,0xe3,0x69,0x21,0xcc,0x30]
1676 ; X86-AVX1-NEXT: ## xmm1 = xmm2[0,1,2],xmm4[0]
1677 ; X86-AVX1-NEXT: vinsertps $48, %xmm4, %xmm3, %xmm2 ## encoding: [0xc4,0xe3,0x61,0x21,0xd4,0x30]
1678 ; X86-AVX1-NEXT: ## xmm2 = xmm3[0,1,2],xmm4[0]
1679 ; X86-AVX1-NEXT: vaddps %xmm2, %xmm1, %xmm1 ## encoding: [0xc5,0xf0,0x58,0xca]
1680 ; X86-AVX1-NEXT: vaddps %xmm1, %xmm0, %xmm0 ## encoding: [0xc5,0xf8,0x58,0xc1]
1681 ; X86-AVX1-NEXT: retl ## encoding: [0xc3]
1683 ; X86-AVX512-LABEL: insertps_from_broadcast_multiple_use:
1684 ; X86-AVX512: ## %bb.0:
1685 ; X86-AVX512-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x08]
1686 ; X86-AVX512-NEXT: movl {{[0-9]+}}(%esp), %ecx ## encoding: [0x8b,0x4c,0x24,0x04]
1687 ; X86-AVX512-NEXT: vbroadcastss (%ecx,%eax,4), %xmm4 ## EVEX TO VEX Compression encoding: [0xc4,0xe2,0x79,0x18,0x24,0x81]
1688 ; X86-AVX512-NEXT: vinsertps $48, %xmm4, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x21,0xc4,0x30]
1689 ; X86-AVX512-NEXT: ## xmm0 = xmm0[0,1,2],xmm4[0]
1690 ; X86-AVX512-NEXT: vinsertps $48, %xmm4, %xmm1, %xmm1 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x71,0x21,0xcc,0x30]
1691 ; X86-AVX512-NEXT: ## xmm1 = xmm1[0,1,2],xmm4[0]
1692 ; X86-AVX512-NEXT: vaddps %xmm1, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc5,0xf8,0x58,0xc1]
1693 ; X86-AVX512-NEXT: vinsertps $48, %xmm4, %xmm2, %xmm1 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x69,0x21,0xcc,0x30]
1694 ; X86-AVX512-NEXT: ## xmm1 = xmm2[0,1,2],xmm4[0]
1695 ; X86-AVX512-NEXT: vinsertps $48, %xmm4, %xmm3, %xmm2 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x61,0x21,0xd4,0x30]
1696 ; X86-AVX512-NEXT: ## xmm2 = xmm3[0,1,2],xmm4[0]
1697 ; X86-AVX512-NEXT: vaddps %xmm2, %xmm1, %xmm1 ## EVEX TO VEX Compression encoding: [0xc5,0xf0,0x58,0xca]
1698 ; X86-AVX512-NEXT: vaddps %xmm1, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc5,0xf8,0x58,0xc1]
1699 ; X86-AVX512-NEXT: retl ## encoding: [0xc3]
1701 ; X64-SSE-LABEL: insertps_from_broadcast_multiple_use:
1702 ; X64-SSE: ## %bb.0:
1703 ; X64-SSE-NEXT: movss (%rdi,%rsi,4), %xmm4 ## encoding: [0xf3,0x0f,0x10,0x24,0xb7]
1704 ; X64-SSE-NEXT: ## xmm4 = mem[0],zero,zero,zero
1705 ; X64-SSE-NEXT: insertps $48, %xmm4, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x21,0xc4,0x30]
1706 ; X64-SSE-NEXT: ## xmm0 = xmm0[0,1,2],xmm4[0]
1707 ; X64-SSE-NEXT: insertps $48, %xmm4, %xmm1 ## encoding: [0x66,0x0f,0x3a,0x21,0xcc,0x30]
1708 ; X64-SSE-NEXT: ## xmm1 = xmm1[0,1,2],xmm4[0]
1709 ; X64-SSE-NEXT: addps %xmm1, %xmm0 ## encoding: [0x0f,0x58,0xc1]
1710 ; X64-SSE-NEXT: insertps $48, %xmm4, %xmm2 ## encoding: [0x66,0x0f,0x3a,0x21,0xd4,0x30]
1711 ; X64-SSE-NEXT: ## xmm2 = xmm2[0,1,2],xmm4[0]
1712 ; X64-SSE-NEXT: insertps $48, %xmm4, %xmm3 ## encoding: [0x66,0x0f,0x3a,0x21,0xdc,0x30]
1713 ; X64-SSE-NEXT: ## xmm3 = xmm3[0,1,2],xmm4[0]
1714 ; X64-SSE-NEXT: addps %xmm2, %xmm3 ## encoding: [0x0f,0x58,0xda]
1715 ; X64-SSE-NEXT: addps %xmm3, %xmm0 ## encoding: [0x0f,0x58,0xc3]
1716 ; X64-SSE-NEXT: retq ## encoding: [0xc3]
1718 ; X64-AVX1-LABEL: insertps_from_broadcast_multiple_use:
1719 ; X64-AVX1: ## %bb.0:
1720 ; X64-AVX1-NEXT: vbroadcastss (%rdi,%rsi,4), %xmm4 ## encoding: [0xc4,0xe2,0x79,0x18,0x24,0xb7]
1721 ; X64-AVX1-NEXT: vinsertps $48, %xmm4, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x21,0xc4,0x30]
1722 ; X64-AVX1-NEXT: ## xmm0 = xmm0[0,1,2],xmm4[0]
1723 ; X64-AVX1-NEXT: vinsertps $48, %xmm4, %xmm1, %xmm1 ## encoding: [0xc4,0xe3,0x71,0x21,0xcc,0x30]
1724 ; X64-AVX1-NEXT: ## xmm1 = xmm1[0,1,2],xmm4[0]
1725 ; X64-AVX1-NEXT: vaddps %xmm1, %xmm0, %xmm0 ## encoding: [0xc5,0xf8,0x58,0xc1]
1726 ; X64-AVX1-NEXT: vinsertps $48, %xmm4, %xmm2, %xmm1 ## encoding: [0xc4,0xe3,0x69,0x21,0xcc,0x30]
1727 ; X64-AVX1-NEXT: ## xmm1 = xmm2[0,1,2],xmm4[0]
1728 ; X64-AVX1-NEXT: vinsertps $48, %xmm4, %xmm3, %xmm2 ## encoding: [0xc4,0xe3,0x61,0x21,0xd4,0x30]
1729 ; X64-AVX1-NEXT: ## xmm2 = xmm3[0,1,2],xmm4[0]
1730 ; X64-AVX1-NEXT: vaddps %xmm2, %xmm1, %xmm1 ## encoding: [0xc5,0xf0,0x58,0xca]
1731 ; X64-AVX1-NEXT: vaddps %xmm1, %xmm0, %xmm0 ## encoding: [0xc5,0xf8,0x58,0xc1]
1732 ; X64-AVX1-NEXT: retq ## encoding: [0xc3]
1734 ; X64-AVX512-LABEL: insertps_from_broadcast_multiple_use:
1735 ; X64-AVX512: ## %bb.0:
1736 ; X64-AVX512-NEXT: vbroadcastss (%rdi,%rsi,4), %xmm4 ## EVEX TO VEX Compression encoding: [0xc4,0xe2,0x79,0x18,0x24,0xb7]
1737 ; X64-AVX512-NEXT: vinsertps $48, %xmm4, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x21,0xc4,0x30]
1738 ; X64-AVX512-NEXT: ## xmm0 = xmm0[0,1,2],xmm4[0]
1739 ; X64-AVX512-NEXT: vinsertps $48, %xmm4, %xmm1, %xmm1 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x71,0x21,0xcc,0x30]
1740 ; X64-AVX512-NEXT: ## xmm1 = xmm1[0,1,2],xmm4[0]
1741 ; X64-AVX512-NEXT: vaddps %xmm1, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc5,0xf8,0x58,0xc1]
1742 ; X64-AVX512-NEXT: vinsertps $48, %xmm4, %xmm2, %xmm1 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x69,0x21,0xcc,0x30]
1743 ; X64-AVX512-NEXT: ## xmm1 = xmm2[0,1,2],xmm4[0]
1744 ; X64-AVX512-NEXT: vinsertps $48, %xmm4, %xmm3, %xmm2 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x61,0x21,0xd4,0x30]
1745 ; X64-AVX512-NEXT: ## xmm2 = xmm3[0,1,2],xmm4[0]
1746 ; X64-AVX512-NEXT: vaddps %xmm2, %xmm1, %xmm1 ## EVEX TO VEX Compression encoding: [0xc5,0xf0,0x58,0xca]
1747 ; X64-AVX512-NEXT: vaddps %xmm1, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc5,0xf8,0x58,0xc1]
1748 ; X64-AVX512-NEXT: retq ## encoding: [0xc3]
1749 %1 = getelementptr inbounds float, float* %fb, i64 %index
1750 %2 = load float, float* %1, align 4
1751 %3 = insertelement <4 x float> undef, float %2, i32 0
1752 %4 = insertelement <4 x float> %3, float %2, i32 1
1753 %5 = insertelement <4 x float> %4, float %2, i32 2
1754 %6 = insertelement <4 x float> %5, float %2, i32 3
1755 %7 = tail call <4 x float> @llvm.x86.sse41.insertps(<4 x float> %a, <4 x float> %6, i32 48)
1756 %8 = tail call <4 x float> @llvm.x86.sse41.insertps(<4 x float> %b, <4 x float> %6, i32 48)
1757 %9 = tail call <4 x float> @llvm.x86.sse41.insertps(<4 x float> %c, <4 x float> %6, i32 48)
1758 %10 = tail call <4 x float> @llvm.x86.sse41.insertps(<4 x float> %d, <4 x float> %6, i32 48)
1759 %11 = fadd <4 x float> %7, %8
1760 %12 = fadd <4 x float> %9, %10
1761 %13 = fadd <4 x float> %11, %12
1765 define <4 x float> @insertps_with_undefs(<4 x float> %a, float* %b) {
1766 ; X86-SSE-LABEL: insertps_with_undefs:
1767 ; X86-SSE: ## %bb.0:
1768 ; X86-SSE-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
1769 ; X86-SSE-NEXT: movss (%eax), %xmm1 ## encoding: [0xf3,0x0f,0x10,0x08]
1770 ; X86-SSE-NEXT: ## xmm1 = mem[0],zero,zero,zero
1771 ; X86-SSE-NEXT: movlhps %xmm0, %xmm1 ## encoding: [0x0f,0x16,0xc8]
1772 ; X86-SSE-NEXT: ## xmm1 = xmm1[0],xmm0[0]
1773 ; X86-SSE-NEXT: movaps %xmm1, %xmm0 ## encoding: [0x0f,0x28,0xc1]
1774 ; X86-SSE-NEXT: retl ## encoding: [0xc3]
1776 ; X86-AVX1-LABEL: insertps_with_undefs:
1777 ; X86-AVX1: ## %bb.0:
1778 ; X86-AVX1-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
1779 ; X86-AVX1-NEXT: vmovss (%eax), %xmm1 ## encoding: [0xc5,0xfa,0x10,0x08]
1780 ; X86-AVX1-NEXT: ## xmm1 = mem[0],zero,zero,zero
1781 ; X86-AVX1-NEXT: vmovlhps %xmm0, %xmm1, %xmm0 ## encoding: [0xc5,0xf0,0x16,0xc0]
1782 ; X86-AVX1-NEXT: ## xmm0 = xmm1[0],xmm0[0]
1783 ; X86-AVX1-NEXT: retl ## encoding: [0xc3]
1785 ; X86-AVX512-LABEL: insertps_with_undefs:
1786 ; X86-AVX512: ## %bb.0:
1787 ; X86-AVX512-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
1788 ; X86-AVX512-NEXT: vmovss (%eax), %xmm1 ## EVEX TO VEX Compression encoding: [0xc5,0xfa,0x10,0x08]
1789 ; X86-AVX512-NEXT: ## xmm1 = mem[0],zero,zero,zero
1790 ; X86-AVX512-NEXT: vmovlhps %xmm0, %xmm1, %xmm0 ## EVEX TO VEX Compression encoding: [0xc5,0xf0,0x16,0xc0]
1791 ; X86-AVX512-NEXT: ## xmm0 = xmm1[0],xmm0[0]
1792 ; X86-AVX512-NEXT: retl ## encoding: [0xc3]
1794 ; X64-SSE-LABEL: insertps_with_undefs:
1795 ; X64-SSE: ## %bb.0:
1796 ; X64-SSE-NEXT: movss (%rdi), %xmm1 ## encoding: [0xf3,0x0f,0x10,0x0f]
1797 ; X64-SSE-NEXT: ## xmm1 = mem[0],zero,zero,zero
1798 ; X64-SSE-NEXT: movlhps %xmm0, %xmm1 ## encoding: [0x0f,0x16,0xc8]
1799 ; X64-SSE-NEXT: ## xmm1 = xmm1[0],xmm0[0]
1800 ; X64-SSE-NEXT: movaps %xmm1, %xmm0 ## encoding: [0x0f,0x28,0xc1]
1801 ; X64-SSE-NEXT: retq ## encoding: [0xc3]
1803 ; X64-AVX1-LABEL: insertps_with_undefs:
1804 ; X64-AVX1: ## %bb.0:
1805 ; X64-AVX1-NEXT: vmovss (%rdi), %xmm1 ## encoding: [0xc5,0xfa,0x10,0x0f]
1806 ; X64-AVX1-NEXT: ## xmm1 = mem[0],zero,zero,zero
1807 ; X64-AVX1-NEXT: vmovlhps %xmm0, %xmm1, %xmm0 ## encoding: [0xc5,0xf0,0x16,0xc0]
1808 ; X64-AVX1-NEXT: ## xmm0 = xmm1[0],xmm0[0]
1809 ; X64-AVX1-NEXT: retq ## encoding: [0xc3]
1811 ; X64-AVX512-LABEL: insertps_with_undefs:
1812 ; X64-AVX512: ## %bb.0:
1813 ; X64-AVX512-NEXT: vmovss (%rdi), %xmm1 ## EVEX TO VEX Compression encoding: [0xc5,0xfa,0x10,0x0f]
1814 ; X64-AVX512-NEXT: ## xmm1 = mem[0],zero,zero,zero
1815 ; X64-AVX512-NEXT: vmovlhps %xmm0, %xmm1, %xmm0 ## EVEX TO VEX Compression encoding: [0xc5,0xf0,0x16,0xc0]
1816 ; X64-AVX512-NEXT: ## xmm0 = xmm1[0],xmm0[0]
1817 ; X64-AVX512-NEXT: retq ## encoding: [0xc3]
1818 %1 = load float, float* %b, align 4
1819 %2 = insertelement <4 x float> undef, float %1, i32 0
1820 %result = shufflevector <4 x float> %a, <4 x float> %2, <4 x i32> <i32 4, i32 undef, i32 0, i32 7>
1821 ret <4 x float> %result
1824 ; Test for a bug in X86ISelLowering.cpp:getINSERTPS where we were using
1825 ; the destination index to change the load, instead of the source index.
1826 define <4 x float> @pr20087(<4 x float> %a, <4 x float> *%ptr) {
1827 ; X86-SSE-LABEL: pr20087:
1828 ; X86-SSE: ## %bb.0:
1829 ; X86-SSE-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
1830 ; X86-SSE-NEXT: movaps (%eax), %xmm1 ## encoding: [0x0f,0x28,0x08]
1831 ; X86-SSE-NEXT: insertps $178, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x21,0xc1,0xb2]
1832 ; X86-SSE-NEXT: ## xmm0 = xmm0[0],zero,xmm0[2],xmm1[2]
1833 ; X86-SSE-NEXT: retl ## encoding: [0xc3]
1835 ; X86-AVX1-LABEL: pr20087:
1836 ; X86-AVX1: ## %bb.0:
1837 ; X86-AVX1-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
1838 ; X86-AVX1-NEXT: vmovaps (%eax), %xmm1 ## encoding: [0xc5,0xf8,0x28,0x08]
1839 ; X86-AVX1-NEXT: vinsertps $178, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x21,0xc1,0xb2]
1840 ; X86-AVX1-NEXT: ## xmm0 = xmm0[0],zero,xmm0[2],xmm1[2]
1841 ; X86-AVX1-NEXT: retl ## encoding: [0xc3]
1843 ; X86-AVX512-LABEL: pr20087:
1844 ; X86-AVX512: ## %bb.0:
1845 ; X86-AVX512-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
1846 ; X86-AVX512-NEXT: vmovaps (%eax), %xmm1 ## EVEX TO VEX Compression encoding: [0xc5,0xf8,0x28,0x08]
1847 ; X86-AVX512-NEXT: vinsertps $178, %xmm1, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x21,0xc1,0xb2]
1848 ; X86-AVX512-NEXT: ## xmm0 = xmm0[0],zero,xmm0[2],xmm1[2]
1849 ; X86-AVX512-NEXT: retl ## encoding: [0xc3]
1851 ; X64-SSE-LABEL: pr20087:
1852 ; X64-SSE: ## %bb.0:
1853 ; X64-SSE-NEXT: movaps (%rdi), %xmm1 ## encoding: [0x0f,0x28,0x0f]
1854 ; X64-SSE-NEXT: insertps $178, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x21,0xc1,0xb2]
1855 ; X64-SSE-NEXT: ## xmm0 = xmm0[0],zero,xmm0[2],xmm1[2]
1856 ; X64-SSE-NEXT: retq ## encoding: [0xc3]
1858 ; X64-AVX1-LABEL: pr20087:
1859 ; X64-AVX1: ## %bb.0:
1860 ; X64-AVX1-NEXT: vmovaps (%rdi), %xmm1 ## encoding: [0xc5,0xf8,0x28,0x0f]
1861 ; X64-AVX1-NEXT: vinsertps $178, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x21,0xc1,0xb2]
1862 ; X64-AVX1-NEXT: ## xmm0 = xmm0[0],zero,xmm0[2],xmm1[2]
1863 ; X64-AVX1-NEXT: retq ## encoding: [0xc3]
1865 ; X64-AVX512-LABEL: pr20087:
1866 ; X64-AVX512: ## %bb.0:
1867 ; X64-AVX512-NEXT: vmovaps (%rdi), %xmm1 ## EVEX TO VEX Compression encoding: [0xc5,0xf8,0x28,0x0f]
1868 ; X64-AVX512-NEXT: vinsertps $178, %xmm1, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x21,0xc1,0xb2]
1869 ; X64-AVX512-NEXT: ## xmm0 = xmm0[0],zero,xmm0[2],xmm1[2]
1870 ; X64-AVX512-NEXT: retq ## encoding: [0xc3]
1871 %load = load <4 x float> , <4 x float> *%ptr
1872 %ret = shufflevector <4 x float> %load, <4 x float> %a, <4 x i32> <i32 4, i32 undef, i32 6, i32 2>
1873 ret <4 x float> %ret
1876 ; Edge case for insertps where we end up with a shuffle with mask=<0, 7, -1, -1>
1877 define void @insertps_pr20411(<4 x i32> %shuffle109, <4 x i32> %shuffle116, i32* noalias nocapture %RET) #1 {
1878 ; X86-SSE-LABEL: insertps_pr20411:
1879 ; X86-SSE: ## %bb.0:
1880 ; X86-SSE-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
1881 ; X86-SSE-NEXT: pshufd $78, %xmm1, %xmm1 ## encoding: [0x66,0x0f,0x70,0xc9,0x4e]
1882 ; X86-SSE-NEXT: ## xmm1 = xmm1[2,3,0,1]
1883 ; X86-SSE-NEXT: pblendw $243, %xmm0, %xmm1 ## encoding: [0x66,0x0f,0x3a,0x0e,0xc8,0xf3]
1884 ; X86-SSE-NEXT: ## xmm1 = xmm0[0,1],xmm1[2,3],xmm0[4,5,6,7]
1885 ; X86-SSE-NEXT: movdqu %xmm1, (%eax) ## encoding: [0xf3,0x0f,0x7f,0x08]
1886 ; X86-SSE-NEXT: retl ## encoding: [0xc3]
1888 ; X86-AVX1-LABEL: insertps_pr20411:
1889 ; X86-AVX1: ## %bb.0:
1890 ; X86-AVX1-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
1891 ; X86-AVX1-NEXT: vpermilps $78, %xmm1, %xmm1 ## encoding: [0xc4,0xe3,0x79,0x04,0xc9,0x4e]
1892 ; X86-AVX1-NEXT: ## xmm1 = xmm1[2,3,0,1]
1893 ; X86-AVX1-NEXT: vblendps $2, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x0c,0xc1,0x02]
1894 ; X86-AVX1-NEXT: ## xmm0 = xmm0[0],xmm1[1],xmm0[2,3]
1895 ; X86-AVX1-NEXT: vmovups %xmm0, (%eax) ## encoding: [0xc5,0xf8,0x11,0x00]
1896 ; X86-AVX1-NEXT: retl ## encoding: [0xc3]
1898 ; X86-AVX512-LABEL: insertps_pr20411:
1899 ; X86-AVX512: ## %bb.0:
1900 ; X86-AVX512-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
1901 ; X86-AVX512-NEXT: vpermilps $78, %xmm1, %xmm1 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x04,0xc9,0x4e]
1902 ; X86-AVX512-NEXT: ## xmm1 = xmm1[2,3,0,1]
1903 ; X86-AVX512-NEXT: vblendps $2, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x0c,0xc1,0x02]
1904 ; X86-AVX512-NEXT: ## xmm0 = xmm0[0],xmm1[1],xmm0[2,3]
1905 ; X86-AVX512-NEXT: vmovups %xmm0, (%eax) ## EVEX TO VEX Compression encoding: [0xc5,0xf8,0x11,0x00]
1906 ; X86-AVX512-NEXT: retl ## encoding: [0xc3]
1908 ; X64-SSE-LABEL: insertps_pr20411:
1909 ; X64-SSE: ## %bb.0:
1910 ; X64-SSE-NEXT: pshufd $78, %xmm1, %xmm1 ## encoding: [0x66,0x0f,0x70,0xc9,0x4e]
1911 ; X64-SSE-NEXT: ## xmm1 = xmm1[2,3,0,1]
1912 ; X64-SSE-NEXT: pblendw $243, %xmm0, %xmm1 ## encoding: [0x66,0x0f,0x3a,0x0e,0xc8,0xf3]
1913 ; X64-SSE-NEXT: ## xmm1 = xmm0[0,1],xmm1[2,3],xmm0[4,5,6,7]
1914 ; X64-SSE-NEXT: movdqu %xmm1, (%rdi) ## encoding: [0xf3,0x0f,0x7f,0x0f]
1915 ; X64-SSE-NEXT: retq ## encoding: [0xc3]
1917 ; X64-AVX1-LABEL: insertps_pr20411:
1918 ; X64-AVX1: ## %bb.0:
1919 ; X64-AVX1-NEXT: vpermilps $78, %xmm1, %xmm1 ## encoding: [0xc4,0xe3,0x79,0x04,0xc9,0x4e]
1920 ; X64-AVX1-NEXT: ## xmm1 = xmm1[2,3,0,1]
1921 ; X64-AVX1-NEXT: vblendps $2, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x0c,0xc1,0x02]
1922 ; X64-AVX1-NEXT: ## xmm0 = xmm0[0],xmm1[1],xmm0[2,3]
1923 ; X64-AVX1-NEXT: vmovups %xmm0, (%rdi) ## encoding: [0xc5,0xf8,0x11,0x07]
1924 ; X64-AVX1-NEXT: retq ## encoding: [0xc3]
1926 ; X64-AVX512-LABEL: insertps_pr20411:
1927 ; X64-AVX512: ## %bb.0:
1928 ; X64-AVX512-NEXT: vpermilps $78, %xmm1, %xmm1 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x04,0xc9,0x4e]
1929 ; X64-AVX512-NEXT: ## xmm1 = xmm1[2,3,0,1]
1930 ; X64-AVX512-NEXT: vblendps $2, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x0c,0xc1,0x02]
1931 ; X64-AVX512-NEXT: ## xmm0 = xmm0[0],xmm1[1],xmm0[2,3]
1932 ; X64-AVX512-NEXT: vmovups %xmm0, (%rdi) ## EVEX TO VEX Compression encoding: [0xc5,0xf8,0x11,0x07]
1933 ; X64-AVX512-NEXT: retq ## encoding: [0xc3]
1934 %shuffle117 = shufflevector <4 x i32> %shuffle109, <4 x i32> %shuffle116, <4 x i32> <i32 0, i32 7, i32 undef, i32 undef>
1935 %ptrcast = bitcast i32* %RET to <4 x i32>*
1936 store <4 x i32> %shuffle117, <4 x i32>* %ptrcast, align 4
1940 define <4 x float> @insertps_4(<4 x float> %A, <4 x float> %B) {
1941 ; SSE-LABEL: insertps_4:
1943 ; SSE-NEXT: insertps $170, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x21,0xc1,0xaa]
1944 ; SSE-NEXT: ## xmm0 = xmm0[0],zero,xmm1[2],zero
1945 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1947 ; AVX1-LABEL: insertps_4:
1949 ; AVX1-NEXT: vinsertps $170, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x21,0xc1,0xaa]
1950 ; AVX1-NEXT: ## xmm0 = xmm0[0],zero,xmm1[2],zero
1951 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1953 ; AVX512-LABEL: insertps_4:
1955 ; AVX512-NEXT: vinsertps $170, %xmm1, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x21,0xc1,0xaa]
1956 ; AVX512-NEXT: ## xmm0 = xmm0[0],zero,xmm1[2],zero
1957 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1958 %vecext = extractelement <4 x float> %A, i32 0
1959 %vecinit = insertelement <4 x float> undef, float %vecext, i32 0
1960 %vecinit1 = insertelement <4 x float> %vecinit, float 0.000000e+00, i32 1
1961 %vecext2 = extractelement <4 x float> %B, i32 2
1962 %vecinit3 = insertelement <4 x float> %vecinit1, float %vecext2, i32 2
1963 %vecinit4 = insertelement <4 x float> %vecinit3, float 0.000000e+00, i32 3
1964 ret <4 x float> %vecinit4
1967 define <4 x float> @insertps_5(<4 x float> %A, <4 x float> %B) {
1968 ; SSE-LABEL: insertps_5:
1970 ; SSE-NEXT: insertps $92, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x21,0xc1,0x5c]
1971 ; SSE-NEXT: ## xmm0 = xmm0[0],xmm1[1],zero,zero
1972 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1974 ; AVX1-LABEL: insertps_5:
1976 ; AVX1-NEXT: vinsertps $92, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x21,0xc1,0x5c]
1977 ; AVX1-NEXT: ## xmm0 = xmm0[0],xmm1[1],zero,zero
1978 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1980 ; AVX512-LABEL: insertps_5:
1982 ; AVX512-NEXT: vpblendd $2, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x02,0xc1,0x02]
1983 ; AVX512-NEXT: ## xmm0 = xmm0[0],xmm1[1],xmm0[2,3]
1984 ; AVX512-NEXT: vmovq %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc5,0xfa,0x7e,0xc0]
1985 ; AVX512-NEXT: ## xmm0 = xmm0[0],zero
1986 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
1987 %vecext = extractelement <4 x float> %A, i32 0
1988 %vecinit = insertelement <4 x float> undef, float %vecext, i32 0
1989 %vecext1 = extractelement <4 x float> %B, i32 1
1990 %vecinit2 = insertelement <4 x float> %vecinit, float %vecext1, i32 1
1991 %vecinit3 = insertelement <4 x float> %vecinit2, float 0.000000e+00, i32 2
1992 %vecinit4 = insertelement <4 x float> %vecinit3, float 0.000000e+00, i32 3
1993 ret <4 x float> %vecinit4
1996 define <4 x float> @insertps_6(<4 x float> %A, <4 x float> %B) {
1997 ; SSE-LABEL: insertps_6:
1999 ; SSE-NEXT: insertps $169, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x21,0xc1,0xa9]
2000 ; SSE-NEXT: ## xmm0 = zero,xmm0[1],xmm1[2],zero
2001 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
2003 ; AVX1-LABEL: insertps_6:
2005 ; AVX1-NEXT: vinsertps $169, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x21,0xc1,0xa9]
2006 ; AVX1-NEXT: ## xmm0 = zero,xmm0[1],xmm1[2],zero
2007 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
2009 ; AVX512-LABEL: insertps_6:
2011 ; AVX512-NEXT: vinsertps $169, %xmm1, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x21,0xc1,0xa9]
2012 ; AVX512-NEXT: ## xmm0 = zero,xmm0[1],xmm1[2],zero
2013 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
2014 %vecext = extractelement <4 x float> %A, i32 1
2015 %vecinit = insertelement <4 x float> <float 0.000000e+00, float undef, float undef, float undef>, float %vecext, i32 1
2016 %vecext1 = extractelement <4 x float> %B, i32 2
2017 %vecinit2 = insertelement <4 x float> %vecinit, float %vecext1, i32 2
2018 %vecinit3 = insertelement <4 x float> %vecinit2, float 0.000000e+00, i32 3
2019 ret <4 x float> %vecinit3
2022 define <4 x float> @insertps_7(<4 x float> %A, <4 x float> %B) {
2023 ; SSE-LABEL: insertps_7:
2025 ; SSE-NEXT: insertps $106, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x21,0xc1,0x6a]
2026 ; SSE-NEXT: ## xmm0 = xmm0[0],zero,xmm1[1],zero
2027 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
2029 ; AVX1-LABEL: insertps_7:
2031 ; AVX1-NEXT: vinsertps $106, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x21,0xc1,0x6a]
2032 ; AVX1-NEXT: ## xmm0 = xmm0[0],zero,xmm1[1],zero
2033 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
2035 ; AVX512-LABEL: insertps_7:
2037 ; AVX512-NEXT: vinsertps $106, %xmm1, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x21,0xc1,0x6a]
2038 ; AVX512-NEXT: ## xmm0 = xmm0[0],zero,xmm1[1],zero
2039 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
2040 %vecext = extractelement <4 x float> %A, i32 0
2041 %vecinit = insertelement <4 x float> undef, float %vecext, i32 0
2042 %vecinit1 = insertelement <4 x float> %vecinit, float 0.000000e+00, i32 1
2043 %vecext2 = extractelement <4 x float> %B, i32 1
2044 %vecinit3 = insertelement <4 x float> %vecinit1, float %vecext2, i32 2
2045 %vecinit4 = insertelement <4 x float> %vecinit3, float 0.000000e+00, i32 3
2046 ret <4 x float> %vecinit4
2049 define <4 x float> @insertps_8(<4 x float> %A, <4 x float> %B) {
2050 ; SSE-LABEL: insertps_8:
2052 ; SSE-NEXT: insertps $28, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x21,0xc1,0x1c]
2053 ; SSE-NEXT: ## xmm0 = xmm0[0],xmm1[0],zero,zero
2054 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
2056 ; AVX1-LABEL: insertps_8:
2058 ; AVX1-NEXT: vinsertps $28, %xmm1, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x21,0xc1,0x1c]
2059 ; AVX1-NEXT: ## xmm0 = xmm0[0],xmm1[0],zero,zero
2060 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
2062 ; AVX512-LABEL: insertps_8:
2064 ; AVX512-NEXT: vinsertps $28, %xmm1, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x21,0xc1,0x1c]
2065 ; AVX512-NEXT: ## xmm0 = xmm0[0],xmm1[0],zero,zero
2066 ; AVX512-NEXT: vmovq %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc5,0xfa,0x7e,0xc0]
2067 ; AVX512-NEXT: ## xmm0 = xmm0[0],zero
2068 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
2069 %vecext = extractelement <4 x float> %A, i32 0
2070 %vecinit = insertelement <4 x float> undef, float %vecext, i32 0
2071 %vecext1 = extractelement <4 x float> %B, i32 0
2072 %vecinit2 = insertelement <4 x float> %vecinit, float %vecext1, i32 1
2073 %vecinit3 = insertelement <4 x float> %vecinit2, float 0.000000e+00, i32 2
2074 %vecinit4 = insertelement <4 x float> %vecinit3, float 0.000000e+00, i32 3
2075 ret <4 x float> %vecinit4
2078 define <4 x float> @insertps_9(<4 x float> %A, <4 x float> %B) {
2079 ; SSE-LABEL: insertps_9:
2081 ; SSE-NEXT: insertps $25, %xmm0, %xmm1 ## encoding: [0x66,0x0f,0x3a,0x21,0xc8,0x19]
2082 ; SSE-NEXT: ## xmm1 = zero,xmm0[0],xmm1[2],zero
2083 ; SSE-NEXT: movaps %xmm1, %xmm0 ## encoding: [0x0f,0x28,0xc1]
2084 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
2086 ; AVX1-LABEL: insertps_9:
2088 ; AVX1-NEXT: vinsertps $25, %xmm0, %xmm1, %xmm0 ## encoding: [0xc4,0xe3,0x71,0x21,0xc0,0x19]
2089 ; AVX1-NEXT: ## xmm0 = zero,xmm0[0],xmm1[2],zero
2090 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
2092 ; AVX512-LABEL: insertps_9:
2094 ; AVX512-NEXT: vinsertps $25, %xmm0, %xmm1, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x71,0x21,0xc0,0x19]
2095 ; AVX512-NEXT: ## xmm0 = zero,xmm0[0],xmm1[2],zero
2096 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
2097 %vecext = extractelement <4 x float> %A, i32 0
2098 %vecinit = insertelement <4 x float> <float 0.000000e+00, float undef, float undef, float undef>, float %vecext, i32 1
2099 %vecext1 = extractelement <4 x float> %B, i32 2
2100 %vecinit2 = insertelement <4 x float> %vecinit, float %vecext1, i32 2
2101 %vecinit3 = insertelement <4 x float> %vecinit2, float 0.000000e+00, i32 3
2102 ret <4 x float> %vecinit3
2105 define <4 x float> @insertps_10(<4 x float> %A) {
2106 ; SSE-LABEL: insertps_10:
2108 ; SSE-NEXT: insertps $42, %xmm0, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x21,0xc0,0x2a]
2109 ; SSE-NEXT: ## xmm0 = xmm0[0],zero,xmm0[0],zero
2110 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
2112 ; AVX1-LABEL: insertps_10:
2114 ; AVX1-NEXT: vinsertps $42, %xmm0, %xmm0, %xmm0 ## encoding: [0xc4,0xe3,0x79,0x21,0xc0,0x2a]
2115 ; AVX1-NEXT: ## xmm0 = xmm0[0],zero,xmm0[0],zero
2116 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
2118 ; AVX512-LABEL: insertps_10:
2120 ; AVX512-NEXT: vinsertps $42, %xmm0, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc4,0xe3,0x79,0x21,0xc0,0x2a]
2121 ; AVX512-NEXT: ## xmm0 = xmm0[0],zero,xmm0[0],zero
2122 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
2123 %vecext = extractelement <4 x float> %A, i32 0
2124 %vecbuild1 = insertelement <4 x float> <float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00>, float %vecext, i32 0
2125 %vecbuild2 = insertelement <4 x float> %vecbuild1, float %vecext, i32 2
2126 ret <4 x float> %vecbuild2
2129 define <4 x float> @build_vector_to_shuffle_1(<4 x float> %A) {
2130 ; SSE-LABEL: build_vector_to_shuffle_1:
2132 ; SSE-NEXT: xorps %xmm1, %xmm1 ## encoding: [0x0f,0x57,0xc9]
2133 ; SSE-NEXT: blendps $5, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x0c,0xc1,0x05]
2134 ; SSE-NEXT: ## xmm0 = xmm1[0],xmm0[1],xmm1[2],xmm0[3]
2135 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
2137 ; AVX1-LABEL: build_vector_to_shuffle_1:
2139 ; AVX1-NEXT: vxorps %xmm1, %xmm1, %xmm1 ## encoding: [0xc5,0xf0,0x57,0xc9]
2140 ; AVX1-NEXT: vblendps $10, %xmm0, %xmm1, %xmm0 ## encoding: [0xc4,0xe3,0x71,0x0c,0xc0,0x0a]
2141 ; AVX1-NEXT: ## xmm0 = xmm1[0],xmm0[1],xmm1[2],xmm0[3]
2142 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
2144 ; AVX512-LABEL: build_vector_to_shuffle_1:
2146 ; AVX512-NEXT: vxorps %xmm1, %xmm1, %xmm1 ## EVEX TO VEX Compression encoding: [0xc5,0xf0,0x57,0xc9]
2147 ; AVX512-NEXT: vblendps $10, %xmm0, %xmm1, %xmm0 ## encoding: [0xc4,0xe3,0x71,0x0c,0xc0,0x0a]
2148 ; AVX512-NEXT: ## xmm0 = xmm1[0],xmm0[1],xmm1[2],xmm0[3]
2149 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
2150 %vecext = extractelement <4 x float> %A, i32 1
2151 %vecinit = insertelement <4 x float> zeroinitializer, float %vecext, i32 1
2152 %vecinit1 = insertelement <4 x float> %vecinit, float 0.0, i32 2
2153 %vecinit3 = shufflevector <4 x float> %vecinit1, <4 x float> %A, <4 x i32> <i32 0, i32 1, i32 2, i32 7>
2154 ret <4 x float> %vecinit3
2157 define <4 x float> @build_vector_to_shuffle_2(<4 x float> %A) {
2158 ; SSE-LABEL: build_vector_to_shuffle_2:
2160 ; SSE-NEXT: xorps %xmm1, %xmm1 ## encoding: [0x0f,0x57,0xc9]
2161 ; SSE-NEXT: blendps $13, %xmm1, %xmm0 ## encoding: [0x66,0x0f,0x3a,0x0c,0xc1,0x0d]
2162 ; SSE-NEXT: ## xmm0 = xmm1[0],xmm0[1],xmm1[2,3]
2163 ; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
2165 ; AVX1-LABEL: build_vector_to_shuffle_2:
2167 ; AVX1-NEXT: vxorps %xmm1, %xmm1, %xmm1 ## encoding: [0xc5,0xf0,0x57,0xc9]
2168 ; AVX1-NEXT: vblendps $2, %xmm0, %xmm1, %xmm0 ## encoding: [0xc4,0xe3,0x71,0x0c,0xc0,0x02]
2169 ; AVX1-NEXT: ## xmm0 = xmm1[0],xmm0[1],xmm1[2,3]
2170 ; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
2172 ; AVX512-LABEL: build_vector_to_shuffle_2:
2174 ; AVX512-NEXT: vxorps %xmm1, %xmm1, %xmm1 ## EVEX TO VEX Compression encoding: [0xc5,0xf0,0x57,0xc9]
2175 ; AVX512-NEXT: vblendps $2, %xmm0, %xmm1, %xmm0 ## encoding: [0xc4,0xe3,0x71,0x0c,0xc0,0x02]
2176 ; AVX512-NEXT: ## xmm0 = xmm1[0],xmm0[1],xmm1[2,3]
2177 ; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
2178 %vecext = extractelement <4 x float> %A, i32 1
2179 %vecinit = insertelement <4 x float> zeroinitializer, float %vecext, i32 1
2180 %vecinit1 = insertelement <4 x float> %vecinit, float 0.0, i32 2
2181 ret <4 x float> %vecinit1