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, ptr %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.p0(ptr %addr, i32 4, <16 x i1>%mask, <16 x i32>undef)
16 define <16 x i32> @test2(<16 x i32> %trigger, ptr %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.p0(ptr %addr, i32 4, <16 x i1>%mask, <16 x i32>zeroinitializer)
27 define void @test3(<16 x i32> %trigger, ptr %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.p0(<16 x i32>%val, ptr %addr, i32 4, <16 x i1>%mask)
39 define <16 x float> @test4(<16 x i32> %trigger, ptr %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.p0(ptr %addr, i32 4, <16 x i1>%mask, <16 x float> %dst)
50 define void @test13(<16 x i32> %trigger, ptr %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.p0(<16 x float>%val, ptr %addr, i32 4, <16 x i1>%mask)
62 define void @one_mask_bit_set5(ptr %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.p0(<8 x double> %val, ptr %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(ptr %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.p0(ptr %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.p0(ptr, i32, <16 x i1>, <16 x i32>)
93 declare void @llvm.masked.store.v16i32.p0(<16 x i32>, ptr, i32, <16 x i1>)
94 declare void @llvm.masked.store.v16f32.p0(<16 x float>, ptr, i32, <16 x i1>)
95 declare <16 x float> @llvm.masked.load.v16f32.p0(ptr, i32, <16 x i1>, <16 x float>)
96 declare <8 x double> @llvm.masked.load.v8f64.p0(ptr, i32, <8 x i1>, <8 x double>)
97 declare void @llvm.masked.store.v8f64.p0(<8 x double>, ptr, i32, <8 x i1>)
99 declare <16 x ptr> @llvm.masked.load.v16p0.p0(ptr, i32, <16 x i1>, <16 x ptr>)
101 define <16 x ptr> @test23(<16 x ptr> %trigger, ptr %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 ptr> %trigger, zeroinitializer
110 %res = call <16 x ptr> @llvm.masked.load.v16p0.p0(ptr %addr, i32 4, <16 x i1>%mask, <16 x ptr>zeroinitializer)
114 %mystruct = type { i16, i16, [1 x ptr] }
117 define <16 x ptr> @test24(<16 x i1> %mask, ptr %addr) {
118 ; AVX512F-LABEL: test24:
120 ; AVX512F-NEXT: vpmovsxbd %xmm0, %zmm0
121 ; AVX512F-NEXT: vpslld $31, %zmm0, %zmm0
122 ; AVX512F-NEXT: vptestmd %zmm0, %zmm0, %k1
123 ; AVX512F-NEXT: vmovdqu64 (%rdi), %zmm0 {%k1} {z}
124 ; AVX512F-NEXT: kshiftrw $8, %k1, %k1
125 ; AVX512F-NEXT: vmovdqu64 64(%rdi), %zmm1 {%k1} {z}
130 ; SKX-NEXT: vpsllw $7, %xmm0, %xmm0
131 ; SKX-NEXT: vpmovb2m %xmm0, %k1
132 ; SKX-NEXT: vmovdqu64 (%rdi), %zmm0 {%k1} {z}
133 ; SKX-NEXT: kshiftrw $8, %k1, %k1
134 ; SKX-NEXT: vmovdqu64 64(%rdi), %zmm1 {%k1} {z}
136 %res = call <16 x ptr> @llvm.masked.load.v16p0.p0(ptr %addr, i32 4, <16 x i1>%mask, <16 x ptr>zeroinitializer)
140 define void @test_store_16i64(ptr %ptrs, <16 x i1> %mask, <16 x i64> %src0) {
141 ; AVX512F-LABEL: test_store_16i64:
143 ; AVX512F-NEXT: vpmovsxbd %xmm0, %zmm0
144 ; AVX512F-NEXT: vpslld $31, %zmm0, %zmm0
145 ; AVX512F-NEXT: vptestmd %zmm0, %zmm0, %k1
146 ; AVX512F-NEXT: vmovdqu64 %zmm1, (%rdi) {%k1}
147 ; AVX512F-NEXT: kshiftrw $8, %k1, %k1
148 ; AVX512F-NEXT: vmovdqu64 %zmm2, 64(%rdi) {%k1}
149 ; AVX512F-NEXT: vzeroupper
152 ; SKX-LABEL: test_store_16i64:
154 ; SKX-NEXT: vpsllw $7, %xmm0, %xmm0
155 ; SKX-NEXT: vpmovb2m %xmm0, %k1
156 ; SKX-NEXT: vmovdqu64 %zmm1, (%rdi) {%k1}
157 ; SKX-NEXT: kshiftrw $8, %k1, %k1
158 ; SKX-NEXT: vmovdqu64 %zmm2, 64(%rdi) {%k1}
159 ; SKX-NEXT: vzeroupper
161 call void @llvm.masked.store.v16i64.p0(<16 x i64> %src0, ptr %ptrs, i32 4, <16 x i1> %mask)
164 declare void @llvm.masked.store.v16i64.p0(<16 x i64> %src0, ptr %ptrs, i32, <16 x i1> %mask)
166 define void @test_store_16f64(ptr %ptrs, <16 x i1> %mask, <16 x double> %src0) {
167 ; AVX512F-LABEL: test_store_16f64:
169 ; AVX512F-NEXT: vpmovsxbd %xmm0, %zmm0
170 ; AVX512F-NEXT: vpslld $31, %zmm0, %zmm0
171 ; AVX512F-NEXT: vptestmd %zmm0, %zmm0, %k1
172 ; AVX512F-NEXT: vmovupd %zmm1, (%rdi) {%k1}
173 ; AVX512F-NEXT: kshiftrw $8, %k1, %k1
174 ; AVX512F-NEXT: vmovupd %zmm2, 64(%rdi) {%k1}
175 ; AVX512F-NEXT: vzeroupper
178 ; SKX-LABEL: test_store_16f64:
180 ; SKX-NEXT: vpsllw $7, %xmm0, %xmm0
181 ; SKX-NEXT: vpmovb2m %xmm0, %k1
182 ; SKX-NEXT: vmovupd %zmm1, (%rdi) {%k1}
183 ; SKX-NEXT: kshiftrw $8, %k1, %k1
184 ; SKX-NEXT: vmovupd %zmm2, 64(%rdi) {%k1}
185 ; SKX-NEXT: vzeroupper
187 call void @llvm.masked.store.v16f64.p0(<16 x double> %src0, ptr %ptrs, i32 4, <16 x i1> %mask)
190 declare void @llvm.masked.store.v16f64.p0(<16 x double> %src0, ptr %ptrs, i32, <16 x i1> %mask)
192 define <16 x i64> @test_load_16i64(ptr %ptrs, <16 x i1> %mask, <16 x i64> %src0) {
193 ; AVX512F-LABEL: test_load_16i64:
195 ; AVX512F-NEXT: vpmovsxbd %xmm0, %zmm0
196 ; AVX512F-NEXT: vpslld $31, %zmm0, %zmm0
197 ; AVX512F-NEXT: vptestmd %zmm0, %zmm0, %k1
198 ; AVX512F-NEXT: vpblendmq (%rdi), %zmm1, %zmm0 {%k1}
199 ; AVX512F-NEXT: kshiftrw $8, %k1, %k1
200 ; AVX512F-NEXT: vpblendmq 64(%rdi), %zmm2, %zmm1 {%k1}
203 ; SKX-LABEL: test_load_16i64:
205 ; SKX-NEXT: vpsllw $7, %xmm0, %xmm0
206 ; SKX-NEXT: vpmovb2m %xmm0, %k1
207 ; SKX-NEXT: vpblendmq (%rdi), %zmm1, %zmm0 {%k1}
208 ; SKX-NEXT: kshiftrw $8, %k1, %k1
209 ; SKX-NEXT: vpblendmq 64(%rdi), %zmm2, %zmm1 {%k1}
211 %res = call <16 x i64> @llvm.masked.load.v16i64.p0(ptr %ptrs, i32 4, <16 x i1> %mask, <16 x i64> %src0)
214 declare <16 x i64> @llvm.masked.load.v16i64.p0(ptr %ptrs, i32, <16 x i1> %mask, <16 x i64> %src0)
216 define <16 x double> @test_load_16f64(ptr %ptrs, <16 x i1> %mask, <16 x double> %src0) {
217 ; AVX512F-LABEL: test_load_16f64:
219 ; AVX512F-NEXT: vpmovsxbd %xmm0, %zmm0
220 ; AVX512F-NEXT: vpslld $31, %zmm0, %zmm0
221 ; AVX512F-NEXT: vptestmd %zmm0, %zmm0, %k1
222 ; AVX512F-NEXT: vblendmpd (%rdi), %zmm1, %zmm0 {%k1}
223 ; AVX512F-NEXT: kshiftrw $8, %k1, %k1
224 ; AVX512F-NEXT: vblendmpd 64(%rdi), %zmm2, %zmm1 {%k1}
227 ; SKX-LABEL: test_load_16f64:
229 ; SKX-NEXT: vpsllw $7, %xmm0, %xmm0
230 ; SKX-NEXT: vpmovb2m %xmm0, %k1
231 ; SKX-NEXT: vblendmpd (%rdi), %zmm1, %zmm0 {%k1}
232 ; SKX-NEXT: kshiftrw $8, %k1, %k1
233 ; SKX-NEXT: vblendmpd 64(%rdi), %zmm2, %zmm1 {%k1}
235 %res = call <16 x double> @llvm.masked.load.v16f64.p0(ptr %ptrs, i32 4, <16 x i1> %mask, <16 x double> %src0)
236 ret <16 x double> %res
238 declare <16 x double> @llvm.masked.load.v16f64.p0(ptr %ptrs, i32, <16 x i1> %mask, <16 x double> %src0)
240 define <32 x double> @test_load_32f64(ptr %ptrs, <32 x i1> %mask, <32 x double> %src0) {
241 ; AVX512F-LABEL: test_load_32f64:
243 ; AVX512F-NEXT: vextracti128 $1, %ymm0, %xmm5
244 ; AVX512F-NEXT: vpmovsxbd %xmm5, %zmm5
245 ; AVX512F-NEXT: vpslld $31, %zmm5, %zmm5
246 ; AVX512F-NEXT: vptestmd %zmm5, %zmm5, %k1
247 ; AVX512F-NEXT: vpmovsxbd %xmm0, %zmm0
248 ; AVX512F-NEXT: vpslld $31, %zmm0, %zmm0
249 ; AVX512F-NEXT: vptestmd %zmm0, %zmm0, %k2
250 ; AVX512F-NEXT: vblendmpd (%rdi), %zmm1, %zmm0 {%k2}
251 ; AVX512F-NEXT: vblendmpd 128(%rdi), %zmm3, %zmm5 {%k1}
252 ; AVX512F-NEXT: kshiftrw $8, %k2, %k2
253 ; AVX512F-NEXT: vblendmpd 64(%rdi), %zmm2, %zmm1 {%k2}
254 ; AVX512F-NEXT: kshiftrw $8, %k1, %k1
255 ; AVX512F-NEXT: vblendmpd 192(%rdi), %zmm4, %zmm3 {%k1}
256 ; AVX512F-NEXT: vmovapd %zmm5, %zmm2
259 ; SKX-LABEL: test_load_32f64:
261 ; SKX-NEXT: vpsllw $7, %ymm0, %ymm0
262 ; SKX-NEXT: vpmovb2m %ymm0, %k1
263 ; SKX-NEXT: vblendmpd (%rdi), %zmm1, %zmm0 {%k1}
264 ; SKX-NEXT: kshiftrw $8, %k1, %k2
265 ; SKX-NEXT: vblendmpd 64(%rdi), %zmm2, %zmm1 {%k2}
266 ; SKX-NEXT: kshiftrd $16, %k1, %k1
267 ; SKX-NEXT: vblendmpd 128(%rdi), %zmm3, %zmm2 {%k1}
268 ; SKX-NEXT: kshiftrw $8, %k1, %k1
269 ; SKX-NEXT: vblendmpd 192(%rdi), %zmm4, %zmm3 {%k1}
271 %res = call <32 x double> @llvm.masked.load.v32f64.p0(ptr %ptrs, i32 4, <32 x i1> %mask, <32 x double> %src0)
272 ret <32 x double> %res
275 declare <32 x double> @llvm.masked.load.v32f64.p0(ptr %ptrs, i32, <32 x i1> %mask, <32 x double> %src0)