1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=sse4.1 | FileCheck %s --check-prefixes=CHECK,SSE
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=avx | FileCheck %s --check-prefixes=CHECK,AVX
6 define <2 x double> @test_x86_sse41_blend_pd(<2 x double> %a0, <2 x double> %a1) {
7 ; CHECK-LABEL: test_x86_sse41_blend_pd:
10 %1 = call <2 x double> @llvm.x86.sse41.blendpd(<2 x double> %a0, <2 x double> %a1, i32 0)
14 define <4 x float> @test_x86_sse41_blend_ps(<4 x float> %a0, <4 x float> %a1) {
15 ; CHECK-LABEL: test_x86_sse41_blend_ps:
18 %1 = call <4 x float> @llvm.x86.sse41.blendps(<4 x float> %a0, <4 x float> %a1, i32 0)
22 define <8 x i16> @test_x86_sse41_pblend_w(<8 x i16> %a0, <8 x i16> %a1) {
23 ; CHECK-LABEL: test_x86_sse41_pblend_w:
26 %1 = call <8 x i16> @llvm.x86.sse41.pblendw(<8 x i16> %a0, <8 x i16> %a1, i32 0)
30 define <2 x double> @test2_x86_sse41_blend_pd(<2 x double> %a0, <2 x double> %a1) {
31 ; SSE-LABEL: test2_x86_sse41_blend_pd:
33 ; SSE-NEXT: movaps %xmm1, %xmm0
36 ; AVX-LABEL: test2_x86_sse41_blend_pd:
38 ; AVX-NEXT: vmovaps %xmm1, %xmm0
40 %1 = call <2 x double> @llvm.x86.sse41.blendpd(<2 x double> %a0, <2 x double> %a1, i32 -1)
44 define <4 x float> @test2_x86_sse41_blend_ps(<4 x float> %a0, <4 x float> %a1) {
45 ; SSE-LABEL: test2_x86_sse41_blend_ps:
47 ; SSE-NEXT: movaps %xmm1, %xmm0
50 ; AVX-LABEL: test2_x86_sse41_blend_ps:
52 ; AVX-NEXT: vmovaps %xmm1, %xmm0
54 %1 = call <4 x float> @llvm.x86.sse41.blendps(<4 x float> %a0, <4 x float> %a1, i32 -1)
58 define <8 x i16> @test2_x86_sse41_pblend_w(<8 x i16> %a0, <8 x i16> %a1) {
59 ; SSE-LABEL: test2_x86_sse41_pblend_w:
61 ; SSE-NEXT: movaps %xmm1, %xmm0
64 ; AVX-LABEL: test2_x86_sse41_pblend_w:
66 ; AVX-NEXT: vmovaps %xmm1, %xmm0
68 %1 = call <8 x i16> @llvm.x86.sse41.pblendw(<8 x i16> %a0, <8 x i16> %a1, i32 -1)
72 define <2 x double> @test3_x86_sse41_blend_pd(<2 x double> %a0) {
73 ; CHECK-LABEL: test3_x86_sse41_blend_pd:
76 %1 = call <2 x double> @llvm.x86.sse41.blendpd(<2 x double> %a0, <2 x double> %a0, i32 7)
80 define <4 x float> @test3_x86_sse41_blend_ps(<4 x float> %a0) {
81 ; CHECK-LABEL: test3_x86_sse41_blend_ps:
84 %1 = call <4 x float> @llvm.x86.sse41.blendps(<4 x float> %a0, <4 x float> %a0, i32 7)
88 define <8 x i16> @test3_x86_sse41_pblend_w(<8 x i16> %a0) {
89 ; CHECK-LABEL: test3_x86_sse41_pblend_w:
92 %1 = call <8 x i16> @llvm.x86.sse41.pblendw(<8 x i16> %a0, <8 x i16> %a0, i32 7)
96 define double @demandedelts_blendvpd(<2 x double> %a0, <2 x double> %a1, <2 x double> %a2) {
97 ; SSE-LABEL: demandedelts_blendvpd:
99 ; SSE-NEXT: movapd %xmm0, %xmm3
100 ; SSE-NEXT: movaps %xmm2, %xmm0
101 ; SSE-NEXT: blendvpd %xmm0, %xmm1, %xmm3
102 ; SSE-NEXT: movapd %xmm3, %xmm0
105 ; AVX-LABEL: demandedelts_blendvpd:
107 ; AVX-NEXT: vblendvpd %xmm2, %xmm1, %xmm0, %xmm0
109 %1 = shufflevector <2 x double> %a0, <2 x double> undef, <2 x i32> zeroinitializer
110 %2 = shufflevector <2 x double> %a1, <2 x double> undef, <2 x i32> zeroinitializer
111 %3 = shufflevector <2 x double> %a2, <2 x double> undef, <2 x i32> zeroinitializer
112 %4 = tail call <2 x double> @llvm.x86.sse41.blendvpd(<2 x double> %1, <2 x double> %2, <2 x double> %3)
113 %5 = extractelement <2 x double> %4, i32 0
117 define float @demandedelts_blendvps(<4 x float> %a0, <4 x float> %a1, <4 x float> %a2) {
118 ; SSE-LABEL: demandedelts_blendvps:
120 ; SSE-NEXT: movaps %xmm0, %xmm3
121 ; SSE-NEXT: movaps %xmm2, %xmm0
122 ; SSE-NEXT: blendvps %xmm0, %xmm1, %xmm3
123 ; SSE-NEXT: movaps %xmm3, %xmm0
126 ; AVX-LABEL: demandedelts_blendvps:
128 ; AVX-NEXT: vblendvps %xmm2, %xmm1, %xmm0, %xmm0
130 %1 = shufflevector <4 x float> %a0, <4 x float> undef, <4 x i32> zeroinitializer
131 %2 = shufflevector <4 x float> %a1, <4 x float> undef, <4 x i32> zeroinitializer
132 %3 = shufflevector <4 x float> %a2, <4 x float> undef, <4 x i32> zeroinitializer
133 %4 = tail call <4 x float> @llvm.x86.sse41.blendvps(<4 x float> %1, <4 x float> %2, <4 x float> %3)
134 %5 = extractelement <4 x float> %4, i32 0
138 define <16 x i8> @demandedelts_pblendvb(<16 x i8> %a0, <16 x i8> %a1, <16 x i8> %a2) {
139 ; SSE-LABEL: demandedelts_pblendvb:
141 ; SSE-NEXT: movdqa %xmm0, %xmm3
142 ; SSE-NEXT: movdqa %xmm2, %xmm0
143 ; SSE-NEXT: pblendvb %xmm0, %xmm1, %xmm3
144 ; SSE-NEXT: pxor %xmm0, %xmm0
145 ; SSE-NEXT: pshufb %xmm0, %xmm3
146 ; SSE-NEXT: movdqa %xmm3, %xmm0
149 ; AVX-LABEL: demandedelts_pblendvb:
151 ; AVX-NEXT: vpblendvb %xmm2, %xmm1, %xmm0, %xmm0
152 ; AVX-NEXT: vpxor %xmm1, %xmm1, %xmm1
153 ; AVX-NEXT: vpshufb %xmm1, %xmm0, %xmm0
155 %1 = shufflevector <16 x i8> %a0, <16 x i8> undef, <16 x i32> zeroinitializer
156 %2 = shufflevector <16 x i8> %a1, <16 x i8> undef, <16 x i32> zeroinitializer
157 %3 = shufflevector <16 x i8> %a2, <16 x i8> undef, <16 x i32> zeroinitializer
158 %4 = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %1, <16 x i8> %2, <16 x i8> %3)
159 %5 = shufflevector <16 x i8> %4, <16 x i8> undef, <16 x i32> zeroinitializer
163 define <2 x i64> @demandedbits_blendvpd(i64 %a0, i64 %a2, <2 x double> %a3) {
164 ; SSE-LABEL: demandedbits_blendvpd:
166 ; SSE-NEXT: movq %rdi, %rax
167 ; SSE-NEXT: orq $1, %rax
168 ; SSE-NEXT: orq $4, %rdi
169 ; SSE-NEXT: movq %rax, %xmm1
170 ; SSE-NEXT: movq %rdi, %xmm2
171 ; SSE-NEXT: movq {{.*#+}} xmm1 = xmm1[0],zero
172 ; SSE-NEXT: movq {{.*#+}} xmm2 = xmm2[0],zero
173 ; SSE-NEXT: blendvpd %xmm0, %xmm2, %xmm1
174 ; SSE-NEXT: psrlq $11, %xmm1
175 ; SSE-NEXT: movdqa %xmm1, %xmm0
178 ; AVX-LABEL: demandedbits_blendvpd:
180 ; AVX-NEXT: movq %rdi, %rax
181 ; AVX-NEXT: orq $1, %rax
182 ; AVX-NEXT: orq $4, %rdi
183 ; AVX-NEXT: vmovq %rax, %xmm1
184 ; AVX-NEXT: vmovq %rdi, %xmm2
185 ; AVX-NEXT: vmovq {{.*#+}} xmm1 = xmm1[0],zero
186 ; AVX-NEXT: vmovq {{.*#+}} xmm2 = xmm2[0],zero
187 ; AVX-NEXT: vblendvpd %xmm0, %xmm2, %xmm1, %xmm0
188 ; AVX-NEXT: vpsrlq $11, %xmm0, %xmm0
192 %3 = bitcast i64 %1 to double
193 %4 = bitcast i64 %2 to double
194 %5 = insertelement <2 x double> zeroinitializer, double %3, i32 0
195 %6 = insertelement <2 x double> zeroinitializer, double %4, i32 0
196 %7 = tail call <2 x double> @llvm.x86.sse41.blendvpd(<2 x double> %5, <2 x double> %6, <2 x double> %a3)
197 %8 = bitcast <2 x double> %7 to <2 x i64>
198 %9 = lshr <2 x i64> %8, <i64 11, i64 11>
202 define <16 x i8> @xor_pblendvb(<16 x i8> %a0, <16 x i8> %a1, <16 x i8> %a2) {
203 ; SSE-LABEL: xor_pblendvb:
205 ; SSE-NEXT: movdqa %xmm0, %xmm3
206 ; SSE-NEXT: movaps %xmm2, %xmm0
207 ; SSE-NEXT: pblendvb %xmm0, %xmm3, %xmm1
208 ; SSE-NEXT: movdqa %xmm1, %xmm0
211 ; AVX-LABEL: xor_pblendvb:
213 ; AVX-NEXT: vpblendvb %xmm2, %xmm0, %xmm1, %xmm0
215 %1 = xor <16 x i8> %a2, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>
216 %2 = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %a0, <16 x i8> %a1, <16 x i8> %1)
220 define <4 x float> @xor_blendvps(<4 x float> %a0, <4 x float> %a1, <4 x float> %a2) {
221 ; SSE-LABEL: xor_blendvps:
223 ; SSE-NEXT: movaps %xmm0, %xmm3
224 ; SSE-NEXT: movaps %xmm2, %xmm0
225 ; SSE-NEXT: blendvps %xmm0, %xmm3, %xmm1
226 ; SSE-NEXT: movaps %xmm1, %xmm0
229 ; AVX-LABEL: xor_blendvps:
231 ; AVX-NEXT: vblendvps %xmm2, %xmm0, %xmm1, %xmm0
233 %1 = bitcast <4 x float> %a2 to <4 x i32>
234 %2 = xor <4 x i32> %1, <i32 -1, i32 -1, i32 -1, i32 -1>
235 %3 = bitcast <4 x i32> %2 to <4 x float>
236 %4 = tail call <4 x float> @llvm.x86.sse41.blendvps(<4 x float> %a0, <4 x float> %a1, <4 x float> %3)
240 define <2 x double> @xor_blendvpd(<2 x double> %a0, <2 x double> %a1, <2 x double> %a2) {
241 ; SSE-LABEL: xor_blendvpd:
243 ; SSE-NEXT: movapd %xmm0, %xmm3
244 ; SSE-NEXT: movaps %xmm2, %xmm0
245 ; SSE-NEXT: blendvpd %xmm0, %xmm3, %xmm1
246 ; SSE-NEXT: movapd %xmm1, %xmm0
249 ; AVX-LABEL: xor_blendvpd:
251 ; AVX-NEXT: vblendvpd %xmm2, %xmm0, %xmm1, %xmm0
253 %1 = bitcast <2 x double> %a2 to <4 x i32>
254 %2 = xor <4 x i32> %1, <i32 -1, i32 -1, i32 -1, i32 -1>
255 %3 = bitcast <4 x i32> %2 to <2 x double>
256 %4 = tail call <2 x double> @llvm.x86.sse41.blendvpd(<2 x double> %a0, <2 x double> %a1, <2 x double> %3)
260 define <16 x i8> @PR47404(<16 x i8> %0, <16 x i8> %1, <16 x i8> %2) {
261 ; SSE-LABEL: PR47404:
263 ; SSE-NEXT: movdqa %xmm0, %xmm3
264 ; SSE-NEXT: movaps %xmm2, %xmm0
265 ; SSE-NEXT: pblendvb %xmm0, %xmm1, %xmm3
266 ; SSE-NEXT: movdqa %xmm3, %xmm0
269 ; AVX-LABEL: PR47404:
271 ; AVX-NEXT: vpblendvb %xmm2, %xmm1, %xmm0, %xmm0
273 %4 = icmp sgt <16 x i8> %2, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>
274 %5 = select <16 x i1> %4, <16 x i8> %0, <16 x i8> %1
278 declare <2 x double> @llvm.x86.sse41.blendpd(<2 x double>, <2 x double>, i32)
279 declare <4 x float> @llvm.x86.sse41.blendps(<4 x float>, <4 x float>, i32)
280 declare <8 x i16> @llvm.x86.sse41.pblendw(<8 x i16>, <8 x i16>, i32)
282 declare <2 x double> @llvm.x86.sse41.blendvpd(<2 x double>, <2 x double>, <2 x double>)
283 declare <4 x float> @llvm.x86.sse41.blendvps(<4 x float>, <4 x float>, <4 x float>)
284 declare <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8>, <16 x i8>, <16 x i8>)