1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+avx2 | FileCheck %s --check-prefix=X86
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2 | 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]
10 ; X86-NEXT: vaddpd {{\.?LCPI[0-9]+_[0-9]+}}, %ymm0, %ymm0
13 ; X64-LABEL: test_broadcast_2f64_4f64:
15 ; X64-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
16 ; X64-NEXT: vaddpd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm0, %ymm0
18 %1 = load <2 x double>, ptr%p
19 %2 = shufflevector <2 x double> %1, <2 x double> undef, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
20 %3 = fadd <4 x double> %2, <double 1.0, double 2.0, double 3.0, double 4.0>
24 define <4 x i64> @test_broadcast_2i64_4i64(ptr%p) nounwind {
25 ; X86-LABEL: test_broadcast_2i64_4i64:
27 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
28 ; X86-NEXT: vbroadcasti128 {{.*#+}} ymm0 = mem[0,1,0,1]
29 ; X86-NEXT: vpaddq {{\.?LCPI[0-9]+_[0-9]+}}, %ymm0, %ymm0
32 ; X64-LABEL: test_broadcast_2i64_4i64:
34 ; X64-NEXT: vbroadcasti128 {{.*#+}} ymm0 = mem[0,1,0,1]
35 ; X64-NEXT: vpaddq {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm0, %ymm0
37 %1 = load <2 x i64>, ptr%p
38 %2 = shufflevector <2 x i64> %1, <2 x i64> undef, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
39 %3 = add <4 x i64> %2, <i64 1, i64 2, i64 3, i64 4>
43 define <8 x float> @test_broadcast_4f32_8f32(ptr%p) nounwind {
44 ; X86-LABEL: test_broadcast_4f32_8f32:
46 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
47 ; X86-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
48 ; X86-NEXT: vaddps {{\.?LCPI[0-9]+_[0-9]+}}, %ymm0, %ymm0
51 ; X64-LABEL: test_broadcast_4f32_8f32:
53 ; X64-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
54 ; X64-NEXT: vaddps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm0, %ymm0
56 %1 = load <4 x float>, ptr%p
57 %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>
58 %3 = fadd <8 x float> %2, <float 1.0, float 2.0, float 3.0, float 4.0, float 5.0, float 6.0, float 7.0, float 8.0>
62 define <8 x i32> @test_broadcast_4i32_8i32(ptr%p) nounwind {
63 ; X86-LABEL: test_broadcast_4i32_8i32:
65 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
66 ; X86-NEXT: vbroadcasti128 {{.*#+}} ymm0 = mem[0,1,0,1]
67 ; X86-NEXT: vpaddd {{\.?LCPI[0-9]+_[0-9]+}}, %ymm0, %ymm0
70 ; X64-LABEL: test_broadcast_4i32_8i32:
72 ; X64-NEXT: vbroadcasti128 {{.*#+}} ymm0 = mem[0,1,0,1]
73 ; X64-NEXT: vpaddd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm0, %ymm0
75 %1 = load <4 x i32>, ptr%p
76 %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>
77 %3 = add <8 x i32> %2, <i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8>
81 define <16 x i16> @test_broadcast_8i16_16i16(ptr%p) nounwind {
82 ; X86-LABEL: test_broadcast_8i16_16i16:
84 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
85 ; X86-NEXT: vbroadcasti128 {{.*#+}} ymm0 = mem[0,1,0,1]
86 ; X86-NEXT: vpaddw {{\.?LCPI[0-9]+_[0-9]+}}, %ymm0, %ymm0
89 ; X64-LABEL: test_broadcast_8i16_16i16:
91 ; X64-NEXT: vbroadcasti128 {{.*#+}} ymm0 = mem[0,1,0,1]
92 ; X64-NEXT: vpaddw {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm0, %ymm0
94 %1 = load <8 x i16>, ptr%p
95 %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>
96 %3 = add <16 x i16> %2, <i16 1, i16 2, i16 3, i16 4, i16 5, i16 6, i16 7, i16 8, i16 9, i16 10, i16 11, i16 12, i16 13, i16 14, i16 15, i16 16>
100 define <32 x i8> @test_broadcast_16i8_32i8(ptr%p) nounwind {
101 ; X86-LABEL: test_broadcast_16i8_32i8:
103 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
104 ; X86-NEXT: vbroadcasti128 {{.*#+}} ymm0 = mem[0,1,0,1]
105 ; X86-NEXT: vpaddb {{\.?LCPI[0-9]+_[0-9]+}}, %ymm0, %ymm0
108 ; X64-LABEL: test_broadcast_16i8_32i8:
110 ; X64-NEXT: vbroadcasti128 {{.*#+}} ymm0 = mem[0,1,0,1]
111 ; X64-NEXT: vpaddb {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm0, %ymm0
113 %1 = load <16 x i8>, ptr%p
114 %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>
115 %3 = add <32 x i8> %2, <i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15, i8 16, i8 17, i8 18, i8 19, i8 20, i8 21, i8 22, i8 23, i8 24, i8 25, i8 26, i8 27, i8 28, i8 29, i8 30, i8 31, i8 32>
119 define <4 x double> @test_broadcast_2f64_4f64_reuse(ptr %p0, ptr %p1) {
120 ; X86-LABEL: test_broadcast_2f64_4f64_reuse:
122 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
123 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
124 ; X86-NEXT: vbroadcastf128 {{.*#+}} ymm1 = mem[0,1,0,1]
125 ; X86-NEXT: vaddpd {{\.?LCPI[0-9]+_[0-9]+}}, %ymm1, %ymm0
126 ; X86-NEXT: vmovapd %xmm1, (%eax)
129 ; X64-LABEL: test_broadcast_2f64_4f64_reuse:
131 ; X64-NEXT: vbroadcastf128 {{.*#+}} ymm1 = mem[0,1,0,1]
132 ; X64-NEXT: vaddpd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm1, %ymm0
133 ; X64-NEXT: vmovapd %xmm1, (%rsi)
135 %1 = load <2 x double>, ptr %p0
136 %2 = shufflevector <2 x double> %1, <2 x double> undef, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
137 %3 = fadd <4 x double> %2, <double 1.0, double 2.0, double 3.0, double 4.0>
138 store <2 x double> %1, ptr %p1
142 define <4 x i64> @test_broadcast_2i64_4i64_reuse(ptr %p0, ptr %p1) {
143 ; X86-LABEL: test_broadcast_2i64_4i64_reuse:
145 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
146 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
147 ; X86-NEXT: vbroadcasti128 {{.*#+}} ymm1 = mem[0,1,0,1]
148 ; X86-NEXT: vpaddq {{\.?LCPI[0-9]+_[0-9]+}}, %ymm1, %ymm0
149 ; X86-NEXT: vmovdqa %xmm1, (%eax)
152 ; X64-LABEL: test_broadcast_2i64_4i64_reuse:
154 ; X64-NEXT: vbroadcasti128 {{.*#+}} ymm1 = mem[0,1,0,1]
155 ; X64-NEXT: vpaddq {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm1, %ymm0
156 ; X64-NEXT: vmovdqa %xmm1, (%rsi)
158 %1 = load <2 x i64>, ptr %p0
159 %2 = shufflevector <2 x i64> %1, <2 x i64> undef, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
160 %3 = add <4 x i64> %2, <i64 1, i64 2, i64 3, i64 4>
161 store <2 x i64> %1, ptr %p1
165 define <8 x float> @test_broadcast_4f32_8f32_reuse(ptr %p0, ptr %p1) {
166 ; X86-LABEL: test_broadcast_4f32_8f32_reuse:
168 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
169 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
170 ; X86-NEXT: vbroadcastf128 {{.*#+}} ymm1 = mem[0,1,0,1]
171 ; X86-NEXT: vaddps {{\.?LCPI[0-9]+_[0-9]+}}, %ymm1, %ymm0
172 ; X86-NEXT: vmovaps %xmm1, (%eax)
175 ; X64-LABEL: test_broadcast_4f32_8f32_reuse:
177 ; X64-NEXT: vbroadcastf128 {{.*#+}} ymm1 = mem[0,1,0,1]
178 ; X64-NEXT: vaddps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm1, %ymm0
179 ; X64-NEXT: vmovaps %xmm1, (%rsi)
181 %1 = load <4 x float>, ptr %p0
182 %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>
183 %3 = fadd <8 x float> %2, <float 1.0, float 2.0, float 3.0, float 4.0, float 5.0, float 6.0, float 7.0, float 8.0>
184 store <4 x float> %1, ptr %p1
188 define <8 x i32> @test_broadcast_4i32_8i32_reuse(ptr %p0, ptr %p1) {
189 ; X86-LABEL: test_broadcast_4i32_8i32_reuse:
191 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
192 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
193 ; X86-NEXT: vbroadcasti128 {{.*#+}} ymm1 = mem[0,1,0,1]
194 ; X86-NEXT: vpaddd {{\.?LCPI[0-9]+_[0-9]+}}, %ymm1, %ymm0
195 ; X86-NEXT: vmovdqa %xmm1, (%eax)
198 ; X64-LABEL: test_broadcast_4i32_8i32_reuse:
200 ; X64-NEXT: vbroadcasti128 {{.*#+}} ymm1 = mem[0,1,0,1]
201 ; X64-NEXT: vpaddd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm1, %ymm0
202 ; X64-NEXT: vmovdqa %xmm1, (%rsi)
204 %1 = load <4 x i32>, ptr %p0
205 %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>
206 %3 = add <8 x i32> %2, <i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8>
207 store <4 x i32> %1, ptr %p1
211 define <16 x i16> @test_broadcast_8i16_16i16_reuse(ptr%p0, ptr%p1) nounwind {
212 ; X86-LABEL: test_broadcast_8i16_16i16_reuse:
214 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
215 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
216 ; X86-NEXT: vbroadcasti128 {{.*#+}} ymm1 = mem[0,1,0,1]
217 ; X86-NEXT: vpaddw {{\.?LCPI[0-9]+_[0-9]+}}, %ymm1, %ymm0
218 ; X86-NEXT: vmovdqa %xmm1, (%eax)
221 ; X64-LABEL: test_broadcast_8i16_16i16_reuse:
223 ; X64-NEXT: vbroadcasti128 {{.*#+}} ymm1 = mem[0,1,0,1]
224 ; X64-NEXT: vpaddw {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm1, %ymm0
225 ; X64-NEXT: vmovdqa %xmm1, (%rsi)
227 %1 = load <8 x i16>, ptr%p0
228 %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>
229 %3 = add <16 x i16> %2, <i16 1, i16 2, i16 3, i16 4, i16 5, i16 6, i16 7, i16 8, i16 9, i16 10, i16 11, i16 12, i16 13, i16 14, i16 15, i16 16>
230 store <8 x i16> %1, ptr %p1
234 define <32 x i8> @test_broadcast_16i8_32i8_reuse(ptr%p0, ptr%p1) nounwind {
235 ; X86-LABEL: test_broadcast_16i8_32i8_reuse:
237 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
238 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
239 ; X86-NEXT: vbroadcasti128 {{.*#+}} ymm1 = mem[0,1,0,1]
240 ; X86-NEXT: vpaddb {{\.?LCPI[0-9]+_[0-9]+}}, %ymm1, %ymm0
241 ; X86-NEXT: vmovdqa %xmm1, (%eax)
244 ; X64-LABEL: test_broadcast_16i8_32i8_reuse:
246 ; X64-NEXT: vbroadcasti128 {{.*#+}} ymm1 = mem[0,1,0,1]
247 ; X64-NEXT: vpaddb {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm1, %ymm0
248 ; X64-NEXT: vmovdqa %xmm1, (%rsi)
250 %1 = load <16 x i8>, ptr%p0
251 %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>
252 %3 = add <32 x i8> %2, <i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15, i8 16, i8 17, i8 18, i8 19, i8 20, i8 21, i8 22, i8 23, i8 24, i8 25, i8 26, i8 27, i8 28, i8 29, i8 30, i8 31, i8 32>
253 store <16 x i8> %1, ptr %p1
257 define <8 x i32> @PR29088(ptr %p0, ptr %p1) {
258 ; X86-LABEL: PR29088:
260 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
261 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
262 ; X86-NEXT: vxorps %xmm1, %xmm1, %xmm1
263 ; X86-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
264 ; X86-NEXT: vmovaps %ymm1, (%eax)
267 ; X64-LABEL: PR29088:
269 ; X64-NEXT: vxorps %xmm1, %xmm1, %xmm1
270 ; X64-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
271 ; X64-NEXT: vmovaps %ymm1, (%rsi)
273 %ld = load <4 x i32>, ptr %p0
274 store <8 x float> zeroinitializer, ptr %p1
275 %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>