1 // REQUIRES: x86-registered-target
2 // RUN: %clang_cc1 -fexperimental-new-pass-manager -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +avx512f -emit-llvm -o - -Wall -Werror | FileCheck --check-prefix=COMMON --check-prefix=COMMONIR --check-prefix=UNCONSTRAINED %s
3 // RUN: %clang_cc1 -fexperimental-new-pass-manager -flax-vector-conversions=none -fms-extensions -fms-compatibility -ffreestanding %s -triple=x86_64-windows-msvc -target-feature +avx512f -emit-llvm -o - -Wall -Werror | FileCheck --check-prefix=COMMON --check-prefix=COMMONIR --check-prefix=UNCONSTRAINED %s
4 // RUN: %clang_cc1 -fexperimental-new-pass-manager -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +avx512f -ffp-exception-behavior=strict -emit-llvm -o - -Wall -Werror | FileCheck --check-prefix=COMMON --check-prefix=COMMONIR --check-prefix=CONSTRAINED %s
5 // RUN: %clang_cc1 -fexperimental-new-pass-manager -flax-vector-conversions=none -fms-compatibility -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +avx512f -ffp-exception-behavior=strict -emit-llvm -o - -Wall -Werror | FileCheck --check-prefix=COMMON --check-prefix=COMMONIR --check-prefix=CONSTRAINED %s
6 // RUN: %clang_cc1 -fexperimental-new-pass-manager -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +avx512f -S -o - -Wall -Werror | FileCheck --check-prefix=COMMON --check-prefix=CHECK-ASM %s
7 // RUN: %clang_cc1 -fexperimental-new-pass-manager -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +avx512f -ffp-exception-behavior=strict -S -o - -Wall -Werror | FileCheck --check-prefix=COMMON --check-prefix=CHECK-ASM %s
8
9 #include <immintrin.h>
10
test_mm512_sqrt_pd(__m512d a)11 __m512d test_mm512_sqrt_pd(__m512d a)
12 {
13 // COMMON-LABEL: test_mm512_sqrt_pd
14 // UNCONSTRAINED: call <8 x double> @llvm.sqrt.v8f64(<8 x double> %{{.*}})
15 // CONSTRAINED: call <8 x double> @llvm.experimental.constrained.sqrt.v8f64(<8 x double> %{{.*}}, metadata !{{.*}})
16 // CHECK-ASM: vsqrtpd
17 return _mm512_sqrt_pd(a);
18 }
19
test_mm512_mask_sqrt_pd(__m512d __W,__mmask8 __U,__m512d __A)20 __m512d test_mm512_mask_sqrt_pd (__m512d __W, __mmask8 __U, __m512d __A)
21 {
22 // COMMON-LABEL: test_mm512_mask_sqrt_pd
23 // UNCONSTRAINED: call <8 x double> @llvm.sqrt.v8f64(<8 x double> %{{.*}})
24 // CONSTRAINED: call <8 x double> @llvm.experimental.constrained.sqrt.v8f64(<8 x double> %{{.*}}, metadata !{{.*}})
25 // CHECK-ASM: vsqrtpd
26 // COMMONIR: bitcast i8 %{{.*}} to <8 x i1>
27 // COMMONIR: select <8 x i1> %{{.*}}, <8 x double> %{{.*}}, <8 x double> %{{.*}}
28 return _mm512_mask_sqrt_pd (__W,__U,__A);
29 }
30
test_mm512_maskz_sqrt_pd(__mmask8 __U,__m512d __A)31 __m512d test_mm512_maskz_sqrt_pd (__mmask8 __U, __m512d __A)
32 {
33 // COMMON-LABEL: test_mm512_maskz_sqrt_pd
34 // UNCONSTRAINED: call <8 x double> @llvm.sqrt.v8f64(<8 x double> %{{.*}})
35 // CONSTRAINED: call <8 x double> @llvm.experimental.constrained.sqrt.v8f64(<8 x double> %{{.*}}, metadata !{{.*}})
36 // CHECK-ASM: vsqrtpd
37 // COMMONIR: bitcast i8 %{{.*}} to <8 x i1>
38 // COMMONIR: select <8 x i1> %{{.*}}, <8 x double> %{{.*}}, <8 x double> {{.*}}
39 return _mm512_maskz_sqrt_pd (__U,__A);
40 }
41
test_mm512_sqrt_ps(__m512 a)42 __m512 test_mm512_sqrt_ps(__m512 a)
43 {
44 // COMMON-LABEL: test_mm512_sqrt_ps
45 // UNCONSTRAINED: call <16 x float> @llvm.sqrt.v16f32(<16 x float> %{{.*}})
46 // CONSTRAINED: call <16 x float> @llvm.experimental.constrained.sqrt.v16f32(<16 x float> %{{.*}}, metadata !{{.*}})
47 // CHECK-ASM: vsqrtps
48 return _mm512_sqrt_ps(a);
49 }
50
test_mm512_mask_sqrt_ps(__m512 __W,__mmask16 __U,__m512 __A)51 __m512 test_mm512_mask_sqrt_ps(__m512 __W, __mmask16 __U, __m512 __A)
52 {
53 // COMMON-LABEL: test_mm512_mask_sqrt_ps
54 // UNCONSTRAINED: call <16 x float> @llvm.sqrt.v16f32(<16 x float> %{{.*}})
55 // CONSTRAINED: call <16 x float> @llvm.experimental.constrained.sqrt.v16f32(<16 x float> %{{.*}}, metadata !{{.*}})
56 // CHECK-ASM: vsqrtps
57 // COMMONIR: bitcast i16 %{{.*}} to <16 x i1>
58 // COMMONIR: select <16 x i1> %{{.*}}, <16 x float> %{{.*}}, <16 x float> %{{.*}}
59 return _mm512_mask_sqrt_ps( __W, __U, __A);
60 }
61
test_mm512_maskz_sqrt_ps(__mmask16 __U,__m512 __A)62 __m512 test_mm512_maskz_sqrt_ps( __mmask16 __U, __m512 __A)
63 {
64 // COMMON-LABEL: test_mm512_maskz_sqrt_ps
65 // UNCONSTRAINED: call <16 x float> @llvm.sqrt.v16f32(<16 x float> %{{.*}})
66 // CONSTRAINED: call <16 x float> @llvm.experimental.constrained.sqrt.v16f32(<16 x float> %{{.*}}, metadata !{{.*}})
67 // CHECK-ASM: vsqrtps
68 // COMMONIR: bitcast i16 %{{.*}} to <16 x i1>
69 // COMMONIR: select <16 x i1> %{{.*}}, <16 x float> %{{.*}}, <16 x float> {{.*}}
70 return _mm512_maskz_sqrt_ps(__U ,__A);
71 }
72
test_mm512_cvt_roundps_ph(__m512 __A)73 __m256i test_mm512_cvt_roundps_ph(__m512 __A)
74 {
75 // COMMON-LABEL: test_mm512_cvt_roundps_ph
76 // COMMONIR: @llvm.x86.avx512.mask.vcvtps2ph.512
77 return _mm512_cvt_roundps_ph(__A, _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC);
78 }
79
test_mm512_mask_cvt_roundps_ph(__m256i __W,__mmask16 __U,__m512 __A)80 __m256i test_mm512_mask_cvt_roundps_ph(__m256i __W , __mmask16 __U, __m512 __A)
81 {
82 // COMMON-LABEL: test_mm512_mask_cvt_roundps_ph
83 // COMMONIR: @llvm.x86.avx512.mask.vcvtps2ph.512
84 return _mm512_mask_cvt_roundps_ph(__W, __U, __A, _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC);
85 }
86
test_mm512_maskz_cvt_roundps_ph(__mmask16 __U,__m512 __A)87 __m256i test_mm512_maskz_cvt_roundps_ph(__mmask16 __U, __m512 __A)
88 {
89 // COMMON-LABEL: test_mm512_maskz_cvt_roundps_ph
90 // COMMONIR: @llvm.x86.avx512.mask.vcvtps2ph.512
91 return _mm512_maskz_cvt_roundps_ph(__U, __A, _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC);
92 }
93
test_mm512_cvt_roundph_ps(__m256i __A)94 __m512 test_mm512_cvt_roundph_ps(__m256i __A)
95 {
96 // COMMON-LABEL: test_mm512_cvt_roundph_ps
97 // COMMONIR: @llvm.x86.avx512.mask.vcvtph2ps.512
98 return _mm512_cvt_roundph_ps(__A, _MM_FROUND_NO_EXC);
99 }
100
test_mm512_mask_cvt_roundph_ps(__m512 __W,__mmask16 __U,__m256i __A)101 __m512 test_mm512_mask_cvt_roundph_ps(__m512 __W, __mmask16 __U, __m256i __A)
102 {
103 // COMMON-LABEL: test_mm512_mask_cvt_roundph_ps
104 // COMMONIR: @llvm.x86.avx512.mask.vcvtph2ps.512
105 return _mm512_mask_cvt_roundph_ps(__W, __U, __A, _MM_FROUND_NO_EXC);
106 }
107
test_mm512_maskz_cvt_roundph_ps(__mmask16 __U,__m256i __A)108 __m512 test_mm512_maskz_cvt_roundph_ps(__mmask16 __U, __m256i __A)
109 {
110 // COMMON-LABEL: test_mm512_maskz_cvt_roundph_ps
111 // COMMONIR: @llvm.x86.avx512.mask.vcvtph2ps.512
112 return _mm512_maskz_cvt_roundph_ps(__U, __A, _MM_FROUND_NO_EXC);
113 }
114
test_mm_mask_sqrt_sd(__m128d __W,__mmask8 __U,__m128d __A,__m128d __B)115 __m128d test_mm_mask_sqrt_sd(__m128d __W, __mmask8 __U, __m128d __A, __m128d __B){
116 // COMMON-LABEL: test_mm_mask_sqrt_sd
117 // COMMONIR: extractelement <2 x double> %{{.*}}, i64 0
118 // UNCONSTRAINED-NEXT: call double @llvm.sqrt.f64(double %{{.*}})
119 // CONSTRAINED-NEXT: call double @llvm.experimental.constrained.sqrt.f64(double %{{.*}}, metadata !{{.*}})
120 // CHECK-ASM: vsqrtsd
121 // COMMONIR-NEXT: extractelement <2 x double> %{{.*}}, i64 0
122 // COMMONIR-NEXT: bitcast i8 %{{.*}} to <8 x i1>
123 // COMMONIR-NEXT: extractelement <8 x i1> %{{.*}}, i64 0
124 // COMMONIR-NEXT: select i1 {{.*}}, double {{.*}}, double {{.*}}
125 // COMMONIR-NEXT: insertelement <2 x double> %{{.*}}, double {{.*}}, i64 0
126 return _mm_mask_sqrt_sd(__W,__U,__A,__B);
127 }
128
test_mm_maskz_sqrt_sd(__mmask8 __U,__m128d __A,__m128d __B)129 __m128d test_mm_maskz_sqrt_sd(__mmask8 __U, __m128d __A, __m128d __B){
130 // COMMON-LABEL: test_mm_maskz_sqrt_sd
131 // COMMONIR: extractelement <2 x double> %{{.*}}, i64 0
132 // UNCONSTRAINED-NEXT: call double @llvm.sqrt.f64(double %{{.*}})
133 // CONSTRAINED-NEXT: call double @llvm.experimental.constrained.sqrt.f64(double %{{.*}}, metadata !{{.*}})
134 // CHECK-ASM: vsqrtsd
135 // COMMONIR-NEXT: extractelement <2 x double> %{{.*}}, i64 0
136 // COMMONIR-NEXT: bitcast i8 %{{.*}} to <8 x i1>
137 // COMMONIR-NEXT: extractelement <8 x i1> %{{.*}}, i64 0
138 // COMMONIR-NEXT: select i1 {{.*}}, double {{.*}}, double {{.*}}
139 // COMMONIR-NEXT: insertelement <2 x double> %{{.*}}, double {{.*}}, i64 0
140 return _mm_maskz_sqrt_sd(__U,__A,__B);
141 }
142
test_mm_mask_sqrt_ss(__m128 __W,__mmask8 __U,__m128 __A,__m128 __B)143 __m128 test_mm_mask_sqrt_ss(__m128 __W, __mmask8 __U, __m128 __A, __m128 __B){
144 // COMMON-LABEL: test_mm_mask_sqrt_ss
145 // COMMONIR: extractelement <4 x float> %{{.*}}, i64 0
146 // UNCONSTRAINED-NEXT: call float @llvm.sqrt.f32(float %{{.*}})
147 // CONSTRAINED-NEXT: call float @llvm.experimental.constrained.sqrt.f32(float %{{.*}}, metadata !{{.*}})
148 // CHECK-ASM: vsqrtss
149 // COMMONIR-NEXT: extractelement <4 x float> %{{.*}}, i64 0
150 // COMMONIR-NEXT: bitcast i8 %{{.*}} to <8 x i1>
151 // COMMONIR-NEXT: extractelement <8 x i1> %{{.*}}, i64 0
152 // COMMONIR-NEXT: select i1 {{.*}}, float {{.*}}, float {{.*}}
153 // COMMONIR-NEXT: insertelement <4 x float> %{{.*}}, float {{.*}}, i64 0
154 return _mm_mask_sqrt_ss(__W,__U,__A,__B);
155 }
156
test_mm_maskz_sqrt_ss(__mmask8 __U,__m128 __A,__m128 __B)157 __m128 test_mm_maskz_sqrt_ss(__mmask8 __U, __m128 __A, __m128 __B){
158 // COMMON-LABEL: test_mm_maskz_sqrt_ss
159 // COMMONIR: extractelement <4 x float> %{{.*}}, i64 0
160 // UNCONSTRAINED-NEXT: call float @llvm.sqrt.f32(float %{{.*}})
161 // CONSTRAINED-NEXT: call float @llvm.experimental.constrained.sqrt.f32(float %{{.*}}, metadata !{{.*}})
162 // CHECK-ASM: vsqrtss
163 // COMMONIR-NEXT: extractelement <4 x float> %{{.*}}, i64 0
164 // COMMONIR-NEXT: bitcast i8 %{{.*}} to <8 x i1>
165 // COMMONIR-NEXT: extractelement <8 x i1> %{{.*}}, i64 0
166 // COMMONIR-NEXT: select i1 {{.*}}, float {{.*}}, float {{.*}}
167 // COMMONIR-NEXT: insertelement <4 x float> %{{.*}}, float {{.*}}, i64 0
168 return _mm_maskz_sqrt_ss(__U,__A,__B);
169 }
170
test_mm512_cvtph_ps(__m256i __A)171 __m512 test_mm512_cvtph_ps (__m256i __A)
172 {
173 // COMMON-LABEL: test_mm512_cvtph_ps
174 // COMMONIR: bitcast <4 x i64> %{{.*}} to <16 x i16>
175 // COMMONIR: bitcast <16 x i16> %{{.*}} to <16 x half>
176 // UNCONSTRAINED: fpext <16 x half> %{{.*}} to <16 x float>
177 // CONSTRAINED: call <16 x float> @llvm.experimental.constrained.fpext.v16f32.v16f16(<16 x half> %{{.*}}, metadata !"fpexcept.strict")
178 return _mm512_cvtph_ps (__A);
179 }
180
test_mm512_mask_cvtph_ps(__m512 __W,__mmask16 __U,__m256i __A)181 __m512 test_mm512_mask_cvtph_ps (__m512 __W, __mmask16 __U, __m256i __A)
182 {
183 // COMMON-LABEL: test_mm512_mask_cvtph_ps
184 // COMMONIR: bitcast <4 x i64> %{{.*}} to <16 x i16>
185 // COMMONIR: bitcast <16 x i16> %{{.*}} to <16 x half>
186 // UNCONSTRAINED: fpext <16 x half> %{{.*}} to <16 x float>
187 // CONSTRAINED: call <16 x float> @llvm.experimental.constrained.fpext.v16f32.v16f16(<16 x half> %{{.*}}, metadata !"fpexcept.strict")
188 // COMMONIR: select <16 x i1> %{{.*}}, <16 x float> %{{.*}}, <16 x float> %{{.*}}
189 return _mm512_mask_cvtph_ps (__W,__U,__A);
190 }
191
test_mm512_maskz_cvtph_ps(__mmask16 __U,__m256i __A)192 __m512 test_mm512_maskz_cvtph_ps (__mmask16 __U, __m256i __A)
193 {
194 // COMMON-LABEL: test_mm512_maskz_cvtph_ps
195 // COMMONIR: bitcast <4 x i64> %{{.*}} to <16 x i16>
196 // COMMONIR: bitcast <16 x i16> %{{.*}} to <16 x half>
197 // UNCONSTRAINED: fpext <16 x half> %{{.*}} to <16 x float>
198 // CONSTRAINED: call <16 x float> @llvm.experimental.constrained.fpext.v16f32.v16f16(<16 x half> %{{.*}}, metadata !"fpexcept.strict")
199 // COMMONIR: select <16 x i1> %{{.*}}, <16 x float> %{{.*}}, <16 x float> %{{.*}}
200 return _mm512_maskz_cvtph_ps (__U,__A);
201 }
202
203