1 // RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-feature +avx512f -emit-llvm -o - -Werror | FileCheck %s
2 
3 // Don't include mm_malloc.h, it's system specific.
4 #define __MM_MALLOC_H
5 
6 #include <immintrin.h>
7 
test_mm512_sqrt_pd(__m512d a)8 __m512d test_mm512_sqrt_pd(__m512d a)
9 {
10   // CHECK-LABEL: @test_mm512_sqrt_pd
11   // CHECK: @llvm.x86.avx512.sqrt.pd.512
12   return _mm512_sqrt_pd(a);
13 }
14 
test_mm512_sqrt_ps(__m512 a)15 __m512 test_mm512_sqrt_ps(__m512 a)
16 {
17   // CHECK-LABEL: @test_mm512_sqrt_ps
18   // CHECK: @llvm.x86.avx512.sqrt.ps.512
19   return _mm512_sqrt_ps(a);
20 }
21 
test_mm512_rsqrt14_pd(__m512d a)22 __m512d test_mm512_rsqrt14_pd(__m512d a)
23 {
24   // CHECK-LABEL: @test_mm512_rsqrt14_pd
25   // CHECK: @llvm.x86.avx512.rsqrt14.pd.512
26   return _mm512_rsqrt14_pd(a);
27 }
28 
test_mm512_rsqrt14_ps(__m512 a)29 __m512 test_mm512_rsqrt14_ps(__m512 a)
30 {
31   // CHECK-LABEL: @test_mm512_rsqrt14_ps
32   // CHECK: @llvm.x86.avx512.rsqrt14.ps.512
33   return _mm512_rsqrt14_ps(a);
34 }
35 
test_mm512_add_ps(__m512 a,__m512 b)36 __m512 test_mm512_add_ps(__m512 a, __m512 b)
37 {
38   // CHECK-LABEL: @test_mm512_add_ps
39   // CHECK: fadd <16 x float>
40   return _mm512_add_ps(a, b);
41 }
42 
test_mm512_add_pd(__m512d a,__m512d b)43 __m512d test_mm512_add_pd(__m512d a, __m512d b)
44 {
45   // CHECK-LABEL: @test_mm512_add_pd
46   // CHECK: fadd <8 x double>
47   return _mm512_add_pd(a, b);
48 }
49 
test_mm512_mul_ps(__m512 a,__m512 b)50 __m512 test_mm512_mul_ps(__m512 a, __m512 b)
51 {
52   // CHECK-LABEL: @test_mm512_mul_ps
53   // CHECK: fmul <16 x float>
54   return _mm512_mul_ps(a, b);
55 }
56 
test_mm512_mul_pd(__m512d a,__m512d b)57 __m512d test_mm512_mul_pd(__m512d a, __m512d b)
58 {
59   // CHECK-LABEL: @test_mm512_mul_pd
60   // CHECK: fmul <8 x double>
61   return _mm512_mul_pd(a, b);
62 }
63 
test_mm512_storeu_ps(void * p,__m512 a)64 void test_mm512_storeu_ps(void *p, __m512 a)
65 {
66   // CHECK-LABEL: @test_mm512_storeu_ps
67   // CHECK: @llvm.x86.avx512.mask.storeu.ps.512
68   _mm512_storeu_ps(p, a);
69 }
70 
test_mm512_storeu_pd(void * p,__m512d a)71 void test_mm512_storeu_pd(void *p, __m512d a)
72 {
73   // CHECK-LABEL: @test_mm512_storeu_pd
74   // CHECK: @llvm.x86.avx512.mask.storeu.pd.512
75   _mm512_storeu_pd(p, a);
76 }
77 
test_mm512_store_ps(void * p,__m512 a)78 void test_mm512_store_ps(void *p, __m512 a)
79 {
80   // CHECK-LABEL: @test_mm512_store_ps
81   // CHECK: store <16 x float>
82   _mm512_store_ps(p, a);
83 }
84 
test_mm512_store_pd(void * p,__m512d a)85 void test_mm512_store_pd(void *p, __m512d a)
86 {
87   // CHECK-LABEL: @test_mm512_store_pd
88   // CHECK: store <8 x double>
89   _mm512_store_pd(p, a);
90 }
91 
test_mm512_loadu_ps(void * p)92 __m512 test_mm512_loadu_ps(void *p)
93 {
94   // CHECK-LABEL: @test_mm512_loadu_ps
95   // CHECK: load <16 x float>* {{.*}}, align 1{{$}}
96   return _mm512_loadu_ps(p);
97 }
98 
test_mm512_loadu_pd(void * p)99 __m512d test_mm512_loadu_pd(void *p)
100 {
101   // CHECK-LABEL: @test_mm512_loadu_pd
102   // CHECK: load <8 x double>* {{.*}}, align 1{{$}}
103   return _mm512_loadu_pd(p);
104 }
105 
test_mm512_set1_pd(double d)106 __m512d test_mm512_set1_pd(double d)
107 {
108   // CHECK-LABEL: @test_mm512_set1_pd
109   // CHECK: insertelement <8 x double> {{.*}}, i32 0
110   // CHECK: insertelement <8 x double> {{.*}}, i32 1
111   // CHECK: insertelement <8 x double> {{.*}}, i32 2
112   // CHECK: insertelement <8 x double> {{.*}}, i32 3
113   // CHECK: insertelement <8 x double> {{.*}}, i32 4
114   // CHECK: insertelement <8 x double> {{.*}}, i32 5
115   // CHECK: insertelement <8 x double> {{.*}}, i32 6
116   // CHECK: insertelement <8 x double> {{.*}}, i32 7
117   return _mm512_set1_pd(d);
118 }
119 
test_mm512_castpd256_pd512(__m256d a)120 __m512d test_mm512_castpd256_pd512(__m256d a)
121 {
122   // CHECK-LABEL: @test_mm512_castpd256_pd512
123   // CHECK: shufflevector <4 x double> {{.*}} <i32 0, i32 1, i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef>
124   return _mm512_castpd256_pd512(a);
125 }
126 
test_mm512_knot(__mmask16 a)127 __mmask16 test_mm512_knot(__mmask16 a)
128 {
129   // CHECK-LABEL: @test_mm512_knot
130   // CHECK: @llvm.x86.avx512.knot.w
131   return _mm512_knot(a);
132 }
133 
test_mm512_valign_epi64(__m512i a,__m512i b)134 __m512i test_mm512_valign_epi64(__m512i a, __m512i b)
135 {
136   // CHECK-LABEL: @test_mm512_valign_epi64
137   // CHECK: @llvm.x86.avx512.mask.valign.q.512
138   return _mm512_valign_epi64(a, b, 2);
139 }
140 
test_mm512_broadcastsd_pd(__m128d a)141 __m512d test_mm512_broadcastsd_pd(__m128d a)
142 {
143   // CHECK-LABEL: @test_mm512_broadcastsd_pd
144   // CHECK: insertelement <8 x double> {{.*}}, i32 0
145   // CHECK: insertelement <8 x double> {{.*}}, i32 1
146   // CHECK: insertelement <8 x double> {{.*}}, i32 2
147   // CHECK: insertelement <8 x double> {{.*}}, i32 3
148   // CHECK: insertelement <8 x double> {{.*}}, i32 4
149   // CHECK: insertelement <8 x double> {{.*}}, i32 5
150   // CHECK: insertelement <8 x double> {{.*}}, i32 6
151   // CHECK: insertelement <8 x double> {{.*}}, i32 7
152   return _mm512_broadcastsd_pd(a);
153 }
154 
test_mm512_fmadd_pd(__m512d a,__m512d b,__m512d c)155 __m512i test_mm512_fmadd_pd(__m512d a, __m512d b, __m512d c)
156 {
157   // CHECK-LABEL: @test_mm512_fmadd_pd
158   // CHECK: @llvm.x86.fma.mask.vfmadd.pd.512
159   return _mm512_fmadd_pd(a, b, c);
160 }
161 
test_mm512_cmpeq_epi32_mask(__m512i __a,__m512i __b)162 __mmask16 test_mm512_cmpeq_epi32_mask(__m512i __a, __m512i __b) {
163   // CHECK-LABEL: @test_mm512_cmpeq_epi32_mask
164   // CHECK: @llvm.x86.avx512.mask.pcmpeq.d.512
165   return (__mmask16)_mm512_cmpeq_epi32_mask(__a, __b);
166 }
167 
test_mm512_mask_cmpeq_epi32_mask(__mmask16 __u,__m512i __a,__m512i __b)168 __mmask16 test_mm512_mask_cmpeq_epi32_mask(__mmask16 __u, __m512i __a, __m512i __b) {
169   // CHECK-LABEL: @test_mm512_mask_cmpeq_epi32_mask
170   // CHECK: @llvm.x86.avx512.mask.pcmpeq.d.512
171   return (__mmask16)_mm512_mask_cmpeq_epi32_mask(__u, __a, __b);
172 }
173 
test_mm512_mask_cmpeq_epi64_mask(__mmask8 __u,__m512i __a,__m512i __b)174 __mmask8 test_mm512_mask_cmpeq_epi64_mask(__mmask8 __u, __m512i __a, __m512i __b) {
175   // CHECK-LABEL: @test_mm512_mask_cmpeq_epi64_mask
176   // CHECK: @llvm.x86.avx512.mask.pcmpeq.q.512
177   return (__mmask8)_mm512_mask_cmpeq_epi64_mask(__u, __a, __b);
178 }
179 
test_mm512_cmpeq_epi64_mask(__m512i __a,__m512i __b)180 __mmask8 test_mm512_cmpeq_epi64_mask(__m512i __a, __m512i __b) {
181   // CHECK-LABEL: @test_mm512_cmpeq_epi64_mask
182   // CHECK: @llvm.x86.avx512.mask.pcmpeq.q.512
183   return (__mmask8)_mm512_cmpeq_epi64_mask(__a, __b);
184 }
185 
test_mm512_unpackhi_pd(__m512d a,__m512d b)186 __m512d test_mm512_unpackhi_pd(__m512d a, __m512d b)
187 {
188   // CHECK-LABEL: @test_mm512_unpackhi_pd
189   // CHECK: shufflevector <8 x double> {{.*}} <i32 1, i32 9, i32 3, i32 11, i32 5, i32 13, i32 7, i32 15>
190   return _mm512_unpackhi_pd(a, b);
191 }
192 
test_mm512_unpacklo_pd(__m512d a,__m512d b)193 __m512d test_mm512_unpacklo_pd(__m512d a, __m512d b)
194 {
195   // CHECK-LABEL: @test_mm512_unpacklo_pd
196   // CHECK: shufflevector <8 x double> {{.*}} <i32 0, i32 8, i32 2, i32 10, i32 4, i32 12, i32 6, i32 14>
197   return _mm512_unpacklo_pd(a, b);
198 }
199 
test_mm512_unpackhi_ps(__m512d a,__m512d b)200 __m512d test_mm512_unpackhi_ps(__m512d a, __m512d b)
201 {
202   // CHECK-LABEL: @test_mm512_unpackhi_ps
203   // CHECK: shufflevector <16 x float> {{.*}} <i32 2, i32 18, i32 3, i32 19, i32 6, i32 22, i32 7, i32 23, i32 10, i32 26, i32 11, i32 27, i32 14, i32 30, i32 15, i32 31>
204   return _mm512_unpackhi_ps(a, b);
205 }
206 
test_mm512_unpacklo_ps(__m512d a,__m512d b)207 __m512d test_mm512_unpacklo_ps(__m512d a, __m512d b)
208 {
209   // CHECK-LABEL: @test_mm512_unpacklo_ps
210   // CHECK: shufflevector <16 x float> {{.*}} <i32 0, i32 16, i32 1, i32 17, i32 4, i32 20, i32 5, i32 21, i32 8, i32 24, i32 9, i32 25, i32 12, i32 28, i32 13, i32 29>
211   return _mm512_unpacklo_ps(a, b);
212 }
213