1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=x86_64-apple-darwin -mattr=avx512f < %s | FileCheck %s --check-prefix=AVX512 --check-prefix=AVX512F
3 ; RUN: llc -mtriple=x86_64-apple-darwin -mattr=avx512f,avx512bw,avx512vl < %s | FileCheck %s --check-prefix=AVX512 --check-prefix=SKX
5 define <16 x i32> @test1(<16 x i32> %trigger, <16 x i32>* %addr) {
8 ; AVX512-NEXT: vptestnmd %zmm0, %zmm0, %k1
9 ; AVX512-NEXT: vmovdqu32 (%rdi), %zmm0 {%k1} {z}
11 %mask = icmp eq <16 x i32> %trigger, zeroinitializer
12 %res = call <16 x i32> @llvm.masked.load.v16i32.p0v16i32(<16 x i32>* %addr, i32 4, <16 x i1>%mask, <16 x i32>undef)
16 define <16 x i32> @test2(<16 x i32> %trigger, <16 x i32>* %addr) {
17 ; AVX512-LABEL: test2:
19 ; AVX512-NEXT: vptestnmd %zmm0, %zmm0, %k1
20 ; AVX512-NEXT: vmovdqu32 (%rdi), %zmm0 {%k1} {z}
22 %mask = icmp eq <16 x i32> %trigger, zeroinitializer
23 %res = call <16 x i32> @llvm.masked.load.v16i32.p0v16i32(<16 x i32>* %addr, i32 4, <16 x i1>%mask, <16 x i32>zeroinitializer)
27 define void @test3(<16 x i32> %trigger, <16 x i32>* %addr, <16 x i32> %val) {
28 ; AVX512-LABEL: test3:
30 ; AVX512-NEXT: vptestnmd %zmm0, %zmm0, %k1
31 ; AVX512-NEXT: vmovdqu32 %zmm1, (%rdi) {%k1}
32 ; AVX512-NEXT: vzeroupper
34 %mask = icmp eq <16 x i32> %trigger, zeroinitializer
35 call void @llvm.masked.store.v16i32.p0v16i32(<16 x i32>%val, <16 x i32>* %addr, i32 4, <16 x i1>%mask)
39 define <16 x float> @test4(<16 x i32> %trigger, <16 x float>* %addr, <16 x float> %dst) {
40 ; AVX512-LABEL: test4:
42 ; AVX512-NEXT: vptestnmd %zmm0, %zmm0, %k1
43 ; AVX512-NEXT: vblendmps (%rdi), %zmm1, %zmm0 {%k1}
45 %mask = icmp eq <16 x i32> %trigger, zeroinitializer
46 %res = call <16 x float> @llvm.masked.load.v16f32.p0v16f32(<16 x float>* %addr, i32 4, <16 x i1>%mask, <16 x float> %dst)
50 define void @test13(<16 x i32> %trigger, <16 x float>* %addr, <16 x float> %val) {
51 ; AVX512-LABEL: test13:
53 ; AVX512-NEXT: vptestnmd %zmm0, %zmm0, %k1
54 ; AVX512-NEXT: vmovups %zmm1, (%rdi) {%k1}
55 ; AVX512-NEXT: vzeroupper
57 %mask = icmp eq <16 x i32> %trigger, zeroinitializer
58 call void @llvm.masked.store.v16f32.p0v16f32(<16 x float>%val, <16 x float>* %addr, i32 4, <16 x i1>%mask)
62 define void @one_mask_bit_set5(<8 x double>* %addr, <8 x double> %val) {
63 ; AVX512-LABEL: one_mask_bit_set5:
65 ; AVX512-NEXT: vextractf32x4 $3, %zmm0, %xmm0
66 ; AVX512-NEXT: vmovlps %xmm0, 48(%rdi)
67 ; AVX512-NEXT: vzeroupper
69 call void @llvm.masked.store.v8f64.p0v8f64(<8 x double> %val, <8 x double>* %addr, i32 4, <8 x i1><i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 true, i1 false>)
73 define <8 x double> @load_one_mask_bit_set5(<8 x double>* %addr, <8 x double> %val) {
75 ; AVX512F-LABEL: load_one_mask_bit_set5:
77 ; AVX512F-NEXT: movb $-128, %al
78 ; AVX512F-NEXT: kmovw %eax, %k1
79 ; AVX512F-NEXT: vbroadcastsd 56(%rdi), %zmm0 {%k1}
82 ; SKX-LABEL: load_one_mask_bit_set5:
84 ; SKX-NEXT: movb $-128, %al
85 ; SKX-NEXT: kmovd %eax, %k1
86 ; SKX-NEXT: vbroadcastsd 56(%rdi), %zmm0 {%k1}
88 %res = call <8 x double> @llvm.masked.load.v8f64.p0v8f64(<8 x double>* %addr, i32 4, <8 x i1><i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 true>, <8 x double> %val)
92 declare <16 x i32> @llvm.masked.load.v16i32.p0v16i32(<16 x i32>*, i32, <16 x i1>, <16 x i32>)
93 declare void @llvm.masked.store.v16i32.p0v16i32(<16 x i32>, <16 x i32>*, i32, <16 x i1>)
94 declare void @llvm.masked.store.v16f32.p0v16f32(<16 x float>, <16 x float>*, i32, <16 x i1>)
95 declare <16 x float> @llvm.masked.load.v16f32.p0v16f32(<16 x float>*, i32, <16 x i1>, <16 x float>)
96 declare <8 x double> @llvm.masked.load.v8f64.p0v8f64(<8 x double>*, i32, <8 x i1>, <8 x double>)
97 declare void @llvm.masked.store.v8f64.p0v8f64(<8 x double>, <8 x double>*, i32, <8 x i1>)
99 declare <16 x i32*> @llvm.masked.load.v16p0i32.p0v16p0i32(<16 x i32*>*, i32, <16 x i1>, <16 x i32*>)
101 define <16 x i32*> @test23(<16 x i32*> %trigger, <16 x i32*>* %addr) {
102 ; AVX512-LABEL: test23:
104 ; AVX512-NEXT: vptestnmq %zmm1, %zmm1, %k1
105 ; AVX512-NEXT: vptestnmq %zmm0, %zmm0, %k2
106 ; AVX512-NEXT: vmovdqu64 (%rdi), %zmm0 {%k2} {z}
107 ; AVX512-NEXT: vmovdqu64 64(%rdi), %zmm1 {%k1} {z}
109 %mask = icmp eq <16 x i32*> %trigger, zeroinitializer
110 %res = call <16 x i32*> @llvm.masked.load.v16p0i32.p0v16p0i32(<16 x i32*>* %addr, i32 4, <16 x i1>%mask, <16 x i32*>zeroinitializer)
114 %mystruct = type { i16, i16, [1 x i8*] }
116 declare <16 x %mystruct*> @llvm.masked.load.v16p0mystruct.p0v16p0mystruct(<16 x %mystruct*>*, i32, <16 x i1>, <16 x %mystruct*>)
118 define <16 x %mystruct*> @test24(<16 x i1> %mask, <16 x %mystruct*>* %addr) {
119 ; AVX512F-LABEL: test24:
121 ; AVX512F-NEXT: vpmovsxbd %xmm0, %zmm0
122 ; AVX512F-NEXT: vpslld $31, %zmm0, %zmm0
123 ; AVX512F-NEXT: vptestmd %zmm0, %zmm0, %k1
124 ; AVX512F-NEXT: vmovdqu64 (%rdi), %zmm0 {%k1} {z}
125 ; AVX512F-NEXT: kshiftrw $8, %k1, %k1
126 ; AVX512F-NEXT: vmovdqu64 64(%rdi), %zmm1 {%k1} {z}
131 ; SKX-NEXT: vpsllw $7, %xmm0, %xmm0
132 ; SKX-NEXT: vpmovb2m %xmm0, %k1
133 ; SKX-NEXT: vmovdqu64 (%rdi), %zmm0 {%k1} {z}
134 ; SKX-NEXT: kshiftrw $8, %k1, %k1
135 ; SKX-NEXT: vmovdqu64 64(%rdi), %zmm1 {%k1} {z}
137 %res = call <16 x %mystruct*> @llvm.masked.load.v16p0mystruct.p0v16p0mystruct(<16 x %mystruct*>* %addr, i32 4, <16 x i1>%mask, <16 x %mystruct*>zeroinitializer)
138 ret <16 x %mystruct*> %res
141 define void @test_store_16i64(<16 x i64>* %ptrs, <16 x i1> %mask, <16 x i64> %src0) {
142 ; AVX512F-LABEL: test_store_16i64:
144 ; AVX512F-NEXT: vpmovsxbd %xmm0, %zmm0
145 ; AVX512F-NEXT: vpslld $31, %zmm0, %zmm0
146 ; AVX512F-NEXT: vptestmd %zmm0, %zmm0, %k1
147 ; AVX512F-NEXT: vmovdqu64 %zmm1, (%rdi) {%k1}
148 ; AVX512F-NEXT: kshiftrw $8, %k1, %k1
149 ; AVX512F-NEXT: vmovdqu64 %zmm2, 64(%rdi) {%k1}
150 ; AVX512F-NEXT: vzeroupper
153 ; SKX-LABEL: test_store_16i64:
155 ; SKX-NEXT: vpsllw $7, %xmm0, %xmm0
156 ; SKX-NEXT: vpmovb2m %xmm0, %k1
157 ; SKX-NEXT: vmovdqu64 %zmm1, (%rdi) {%k1}
158 ; SKX-NEXT: kshiftrw $8, %k1, %k1
159 ; SKX-NEXT: vmovdqu64 %zmm2, 64(%rdi) {%k1}
160 ; SKX-NEXT: vzeroupper
162 call void @llvm.masked.store.v16i64.p0v16i64(<16 x i64> %src0, <16 x i64>* %ptrs, i32 4, <16 x i1> %mask)
165 declare void @llvm.masked.store.v16i64.p0v16i64(<16 x i64> %src0, <16 x i64>* %ptrs, i32, <16 x i1> %mask)
167 define void @test_store_16f64(<16 x double>* %ptrs, <16 x i1> %mask, <16 x double> %src0) {
168 ; AVX512F-LABEL: test_store_16f64:
170 ; AVX512F-NEXT: vpmovsxbd %xmm0, %zmm0
171 ; AVX512F-NEXT: vpslld $31, %zmm0, %zmm0
172 ; AVX512F-NEXT: vptestmd %zmm0, %zmm0, %k1
173 ; AVX512F-NEXT: vmovupd %zmm1, (%rdi) {%k1}
174 ; AVX512F-NEXT: kshiftrw $8, %k1, %k1
175 ; AVX512F-NEXT: vmovupd %zmm2, 64(%rdi) {%k1}
176 ; AVX512F-NEXT: vzeroupper
179 ; SKX-LABEL: test_store_16f64:
181 ; SKX-NEXT: vpsllw $7, %xmm0, %xmm0
182 ; SKX-NEXT: vpmovb2m %xmm0, %k1
183 ; SKX-NEXT: vmovupd %zmm1, (%rdi) {%k1}
184 ; SKX-NEXT: kshiftrw $8, %k1, %k1
185 ; SKX-NEXT: vmovupd %zmm2, 64(%rdi) {%k1}
186 ; SKX-NEXT: vzeroupper
188 call void @llvm.masked.store.v16f64.p0v16f64(<16 x double> %src0, <16 x double>* %ptrs, i32 4, <16 x i1> %mask)
191 declare void @llvm.masked.store.v16f64.p0v16f64(<16 x double> %src0, <16 x double>* %ptrs, i32, <16 x i1> %mask)
193 define <16 x i64> @test_load_16i64(<16 x i64>* %ptrs, <16 x i1> %mask, <16 x i64> %src0) {
194 ; AVX512F-LABEL: test_load_16i64:
196 ; AVX512F-NEXT: vpmovsxbd %xmm0, %zmm0
197 ; AVX512F-NEXT: vpslld $31, %zmm0, %zmm0
198 ; AVX512F-NEXT: vptestmd %zmm0, %zmm0, %k1
199 ; AVX512F-NEXT: vpblendmq (%rdi), %zmm1, %zmm0 {%k1}
200 ; AVX512F-NEXT: kshiftrw $8, %k1, %k1
201 ; AVX512F-NEXT: vpblendmq 64(%rdi), %zmm2, %zmm1 {%k1}
204 ; SKX-LABEL: test_load_16i64:
206 ; SKX-NEXT: vpsllw $7, %xmm0, %xmm0
207 ; SKX-NEXT: vpmovb2m %xmm0, %k1
208 ; SKX-NEXT: vpblendmq (%rdi), %zmm1, %zmm0 {%k1}
209 ; SKX-NEXT: kshiftrw $8, %k1, %k1
210 ; SKX-NEXT: vpblendmq 64(%rdi), %zmm2, %zmm1 {%k1}
212 %res = call <16 x i64> @llvm.masked.load.v16i64.p0v16i64(<16 x i64>* %ptrs, i32 4, <16 x i1> %mask, <16 x i64> %src0)
215 declare <16 x i64> @llvm.masked.load.v16i64.p0v16i64(<16 x i64>* %ptrs, i32, <16 x i1> %mask, <16 x i64> %src0)
217 define <16 x double> @test_load_16f64(<16 x double>* %ptrs, <16 x i1> %mask, <16 x double> %src0) {
218 ; AVX512F-LABEL: test_load_16f64:
220 ; AVX512F-NEXT: vpmovsxbd %xmm0, %zmm0
221 ; AVX512F-NEXT: vpslld $31, %zmm0, %zmm0
222 ; AVX512F-NEXT: vptestmd %zmm0, %zmm0, %k1
223 ; AVX512F-NEXT: vblendmpd (%rdi), %zmm1, %zmm0 {%k1}
224 ; AVX512F-NEXT: kshiftrw $8, %k1, %k1
225 ; AVX512F-NEXT: vblendmpd 64(%rdi), %zmm2, %zmm1 {%k1}
228 ; SKX-LABEL: test_load_16f64:
230 ; SKX-NEXT: vpsllw $7, %xmm0, %xmm0
231 ; SKX-NEXT: vpmovb2m %xmm0, %k1
232 ; SKX-NEXT: vblendmpd (%rdi), %zmm1, %zmm0 {%k1}
233 ; SKX-NEXT: kshiftrw $8, %k1, %k1
234 ; SKX-NEXT: vblendmpd 64(%rdi), %zmm2, %zmm1 {%k1}
236 %res = call <16 x double> @llvm.masked.load.v16f64.p0v16f64(<16 x double>* %ptrs, i32 4, <16 x i1> %mask, <16 x double> %src0)
237 ret <16 x double> %res
239 declare <16 x double> @llvm.masked.load.v16f64.p0v16f64(<16 x double>* %ptrs, i32, <16 x i1> %mask, <16 x double> %src0)
241 define <32 x double> @test_load_32f64(<32 x double>* %ptrs, <32 x i1> %mask, <32 x double> %src0) {
242 ; AVX512F-LABEL: test_load_32f64:
244 ; AVX512F-NEXT: vextracti128 $1, %ymm0, %xmm5
245 ; AVX512F-NEXT: vpmovsxbd %xmm5, %zmm5
246 ; AVX512F-NEXT: vpslld $31, %zmm5, %zmm5
247 ; AVX512F-NEXT: vptestmd %zmm5, %zmm5, %k1
248 ; AVX512F-NEXT: vpmovsxbd %xmm0, %zmm0
249 ; AVX512F-NEXT: vpslld $31, %zmm0, %zmm0
250 ; AVX512F-NEXT: vptestmd %zmm0, %zmm0, %k2
251 ; AVX512F-NEXT: vblendmpd (%rdi), %zmm1, %zmm0 {%k2}
252 ; AVX512F-NEXT: vblendmpd 128(%rdi), %zmm3, %zmm5 {%k1}
253 ; AVX512F-NEXT: kshiftrw $8, %k2, %k2
254 ; AVX512F-NEXT: vblendmpd 64(%rdi), %zmm2, %zmm1 {%k2}
255 ; AVX512F-NEXT: kshiftrw $8, %k1, %k1
256 ; AVX512F-NEXT: vblendmpd 192(%rdi), %zmm4, %zmm3 {%k1}
257 ; AVX512F-NEXT: vmovapd %zmm5, %zmm2
260 ; SKX-LABEL: test_load_32f64:
262 ; SKX-NEXT: vpsllw $7, %ymm0, %ymm0
263 ; SKX-NEXT: vpmovb2m %ymm0, %k1
264 ; SKX-NEXT: vblendmpd (%rdi), %zmm1, %zmm0 {%k1}
265 ; SKX-NEXT: kshiftrw $8, %k1, %k2
266 ; SKX-NEXT: vblendmpd 64(%rdi), %zmm2, %zmm1 {%k2}
267 ; SKX-NEXT: kshiftrd $16, %k1, %k1
268 ; SKX-NEXT: vblendmpd 128(%rdi), %zmm3, %zmm2 {%k1}
269 ; SKX-NEXT: kshiftrw $8, %k1, %k1
270 ; SKX-NEXT: vblendmpd 192(%rdi), %zmm4, %zmm3 {%k1}
272 %res = call <32 x double> @llvm.masked.load.v32f64.p0v32f64(<32 x double>* %ptrs, i32 4, <32 x i1> %mask, <32 x double> %src0)
273 ret <32 x double> %res
276 declare <32 x double> @llvm.masked.load.v32f64.p0v32f64(<32 x double>* %ptrs, i32, <32 x i1> %mask, <32 x double> %src0)