1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+avx | FileCheck %s --check-prefix=X86
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx | FileCheck %s --check-prefix=X64
5 define <4 x double> @test_broadcast_2f64_4f64(ptr%p) nounwind {
6 ; X86-LABEL: test_broadcast_2f64_4f64:
8 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
9 ; X86-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
12 ; X64-LABEL: test_broadcast_2f64_4f64:
14 ; X64-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
16 %1 = load <2 x double>, ptr%p
17 %2 = shufflevector <2 x double> %1, <2 x double> undef, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
21 define <4 x i64> @test_broadcast_2i64_4i64(ptr%p) nounwind {
22 ; X86-LABEL: test_broadcast_2i64_4i64:
24 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
25 ; X86-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
28 ; X64-LABEL: test_broadcast_2i64_4i64:
30 ; X64-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
32 %1 = load <2 x i64>, ptr%p
33 %2 = shufflevector <2 x i64> %1, <2 x i64> undef, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
37 define <8 x float> @test_broadcast_4f32_8f32(ptr%p) nounwind {
38 ; X86-LABEL: test_broadcast_4f32_8f32:
40 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
41 ; X86-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
44 ; X64-LABEL: test_broadcast_4f32_8f32:
46 ; X64-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
48 %1 = load <4 x float>, ptr%p
49 %2 = shufflevector <4 x float> %1, <4 x float> undef, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 0, i32 1, i32 2, i32 3>
53 define <8 x i32> @test_broadcast_4i32_8i32(ptr%p) nounwind {
54 ; X86-LABEL: test_broadcast_4i32_8i32:
56 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
57 ; X86-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
60 ; X64-LABEL: test_broadcast_4i32_8i32:
62 ; X64-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
64 %1 = load <4 x i32>, ptr%p
65 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 0, i32 1, i32 2, i32 3>
69 define <16 x i16> @test_broadcast_8i16_16i16(ptr%p) nounwind {
70 ; X86-LABEL: test_broadcast_8i16_16i16:
72 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
73 ; X86-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
76 ; X64-LABEL: test_broadcast_8i16_16i16:
78 ; X64-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
80 %1 = load <8 x i16>, ptr%p
81 %2 = shufflevector <8 x i16> %1, <8 x i16> undef, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
85 define <32 x i8> @test_broadcast_16i8_32i8(ptr%p) nounwind {
86 ; X86-LABEL: test_broadcast_16i8_32i8:
88 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
89 ; X86-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
92 ; X64-LABEL: test_broadcast_16i8_32i8:
94 ; X64-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
96 %1 = load <16 x i8>, ptr%p
97 %2 = shufflevector <16 x i8> %1, <16 x i8> undef, <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
101 ; PR38949 - https://bugs.llvm.org/show_bug.cgi?id=38949
102 ; Don't limit the transform based on extra uses of the load itself (the store is a user of the load's chain value).
104 define void @subv_reuse_is_ok(ptr %a, ptr %b) {
105 ; X86-LABEL: subv_reuse_is_ok:
107 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
108 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
109 ; X86-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
110 ; X86-NEXT: vmovups %ymm0, (%eax)
111 ; X86-NEXT: vzeroupper
114 ; X64-LABEL: subv_reuse_is_ok:
116 ; X64-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
117 ; X64-NEXT: vmovups %ymm0, (%rsi)
118 ; X64-NEXT: vzeroupper
120 %ld = load <4 x float>, ptr %a, align 1
121 %splat128 = shufflevector <4 x float> %ld, <4 x float> undef, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 0, i32 1, i32 2, i32 3>
122 store <8 x float> %splat128, ptr %b, align 16
126 define <4 x double> @test_broadcast_2f64_4f64_reuse(ptr %p0, ptr %p1) {
127 ; X86-LABEL: test_broadcast_2f64_4f64_reuse:
129 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
130 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
131 ; X86-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
132 ; X86-NEXT: vmovaps %xmm0, (%eax)
135 ; X64-LABEL: test_broadcast_2f64_4f64_reuse:
137 ; X64-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
138 ; X64-NEXT: vmovaps %xmm0, (%rsi)
140 %1 = load <2 x double>, ptr %p0
141 %2 = shufflevector <2 x double> %1, <2 x double> undef, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
142 store <2 x double> %1, ptr %p1
146 define <4 x i64> @test_broadcast_2i64_4i64_reuse(ptr %p0, ptr %p1) {
147 ; X86-LABEL: test_broadcast_2i64_4i64_reuse:
149 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
150 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
151 ; X86-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
152 ; X86-NEXT: vmovaps %xmm0, (%eax)
155 ; X64-LABEL: test_broadcast_2i64_4i64_reuse:
157 ; X64-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
158 ; X64-NEXT: vmovaps %xmm0, (%rsi)
160 %1 = load <2 x i64>, ptr %p0
161 %2 = shufflevector <2 x i64> %1, <2 x i64> undef, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
162 store <2 x i64> %1, ptr %p1
166 define <8 x float> @test_broadcast_4f32_8f32_reuse(ptr %p0, ptr %p1) {
167 ; X86-LABEL: test_broadcast_4f32_8f32_reuse:
169 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
170 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
171 ; X86-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
172 ; X86-NEXT: vmovaps %xmm0, (%eax)
175 ; X64-LABEL: test_broadcast_4f32_8f32_reuse:
177 ; X64-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
178 ; X64-NEXT: vmovaps %xmm0, (%rsi)
180 %1 = load <4 x float>, ptr %p0
181 %2 = shufflevector <4 x float> %1, <4 x float> undef, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 0, i32 1, i32 2, i32 3>
182 store <4 x float> %1, ptr %p1
186 define <8 x i32> @test_broadcast_4i32_8i32_reuse(ptr %p0, ptr %p1) {
187 ; X86-LABEL: test_broadcast_4i32_8i32_reuse:
189 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
190 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
191 ; X86-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
192 ; X86-NEXT: vmovaps %xmm0, (%eax)
195 ; X64-LABEL: test_broadcast_4i32_8i32_reuse:
197 ; X64-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
198 ; X64-NEXT: vmovaps %xmm0, (%rsi)
200 %1 = load <4 x i32>, ptr %p0
201 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 0, i32 1, i32 2, i32 3>
202 store <4 x i32> %1, ptr %p1
206 define <16 x i16> @test_broadcast_8i16_16i16_reuse(ptr%p0, ptr%p1) nounwind {
207 ; X86-LABEL: test_broadcast_8i16_16i16_reuse:
209 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
210 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
211 ; X86-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
212 ; X86-NEXT: vmovaps %xmm0, (%eax)
215 ; X64-LABEL: test_broadcast_8i16_16i16_reuse:
217 ; X64-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
218 ; X64-NEXT: vmovaps %xmm0, (%rsi)
220 %1 = load <8 x i16>, ptr%p0
221 %2 = shufflevector <8 x i16> %1, <8 x i16> undef, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
222 store <8 x i16> %1, ptr %p1
226 define <32 x i8> @test_broadcast_16i8_32i8_reuse(ptr%p0, ptr%p1) nounwind {
227 ; X86-LABEL: test_broadcast_16i8_32i8_reuse:
229 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
230 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
231 ; X86-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
232 ; X86-NEXT: vmovaps %xmm0, (%eax)
235 ; X64-LABEL: test_broadcast_16i8_32i8_reuse:
237 ; X64-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
238 ; X64-NEXT: vmovaps %xmm0, (%rsi)
240 %1 = load <16 x i8>, ptr%p0
241 %2 = shufflevector <16 x i8> %1, <16 x i8> undef, <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
242 store <16 x i8> %1, ptr %p1
246 define <8 x i32> @PR29088(ptr %p0, ptr %p1) {
247 ; X86-LABEL: PR29088:
249 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
250 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
251 ; X86-NEXT: vxorps %xmm1, %xmm1, %xmm1
252 ; X86-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
253 ; X86-NEXT: vmovaps %ymm1, (%eax)
256 ; X64-LABEL: PR29088:
258 ; X64-NEXT: vxorps %xmm1, %xmm1, %xmm1
259 ; X64-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
260 ; X64-NEXT: vmovaps %ymm1, (%rsi)
262 %ld = load <4 x i32>, ptr %p0
263 store <8 x float> zeroinitializer, ptr %p1
264 %shuf = shufflevector <4 x i32> %ld, <4 x i32> undef, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 0, i32 1, i32 2, i32 3>