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=X32
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(<2 x double> *%p) nounwind {
6 ; X32-LABEL: test_broadcast_2f64_4f64:
8 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
9 ; X32-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>, <2 x double> *%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(<2 x i64> *%p) nounwind {
22 ; X32-LABEL: test_broadcast_2i64_4i64:
24 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
25 ; X32-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>, <2 x i64> *%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(<4 x float> *%p) nounwind {
38 ; X32-LABEL: test_broadcast_4f32_8f32:
40 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
41 ; X32-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>, <4 x float> *%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(<4 x i32> *%p) nounwind {
54 ; X32-LABEL: test_broadcast_4i32_8i32:
56 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
57 ; X32-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>, <4 x i32> *%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(<8 x i16> *%p) nounwind {
70 ; X32-LABEL: test_broadcast_8i16_16i16:
72 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
73 ; X32-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>, <8 x i16> *%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(<16 x i8> *%p) nounwind {
86 ; X32-LABEL: test_broadcast_16i8_32i8:
88 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
89 ; X32-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>, <16 x i8> *%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(<4 x float>* %a, <8 x float>* %b) {
105 ; X32-LABEL: subv_reuse_is_ok:
107 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
108 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx
109 ; X32-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
110 ; X32-NEXT: vmovups %ymm0, (%eax)
111 ; X32-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>, <4 x float>* %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, <8 x float>* %b, align 16
126 define <4 x double> @test_broadcast_2f64_4f64_reuse(<2 x double>* %p0, <2 x double>* %p1) {
127 ; X32-LABEL: test_broadcast_2f64_4f64_reuse:
129 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
130 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx
131 ; X32-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
132 ; X32-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>, <2 x double>* %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, <2 x double>* %p1
146 define <4 x i64> @test_broadcast_2i64_4i64_reuse(<2 x i64>* %p0, <2 x i64>* %p1) {
147 ; X32-LABEL: test_broadcast_2i64_4i64_reuse:
149 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
150 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx
151 ; X32-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
152 ; X32-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>, <2 x i64>* %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, <2 x i64>* %p1
166 define <8 x float> @test_broadcast_4f32_8f32_reuse(<4 x float>* %p0, <4 x float>* %p1) {
167 ; X32-LABEL: test_broadcast_4f32_8f32_reuse:
169 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
170 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx
171 ; X32-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
172 ; X32-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>, <4 x float>* %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, <4 x float>* %p1
186 define <8 x i32> @test_broadcast_4i32_8i32_reuse(<4 x i32>* %p0, <4 x i32>* %p1) {
187 ; X32-LABEL: test_broadcast_4i32_8i32_reuse:
189 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
190 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx
191 ; X32-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
192 ; X32-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>, <4 x i32>* %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, <4 x i32>* %p1
206 define <16 x i16> @test_broadcast_8i16_16i16_reuse(<8 x i16> *%p0, <8 x i16> *%p1) nounwind {
207 ; X32-LABEL: test_broadcast_8i16_16i16_reuse:
209 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
210 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx
211 ; X32-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
212 ; X32-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>, <8 x i16> *%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, <8 x i16>* %p1
226 define <32 x i8> @test_broadcast_16i8_32i8_reuse(<16 x i8> *%p0, <16 x i8> *%p1) nounwind {
227 ; X32-LABEL: test_broadcast_16i8_32i8_reuse:
229 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
230 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx
231 ; X32-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
232 ; X32-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>, <16 x i8> *%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, <16 x i8>* %p1
246 define <8 x i32> @PR29088(<4 x i32>* %p0, <8 x float>* %p1) {
247 ; X32-LABEL: PR29088:
249 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
250 ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx
251 ; X32-NEXT: vxorps %xmm1, %xmm1, %xmm1
252 ; X32-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1]
253 ; X32-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>, <4 x i32>* %p0
263 store <8 x float> zeroinitializer, <8 x float>* %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>