[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CodeGen / X86 / avx512f-builtins-constrained.c
blob4044021a3f9e0ac0d8fd4595837d3918c1b54858
1 // REQUIRES: x86-registered-target
2 // RUN: %clang_cc1 -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 -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 -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +avx512f -ffp-exception-behavior=maytrap -DSTRICT=1 -emit-llvm -o - -Wall -Werror | FileCheck --check-prefix=COMMON --check-prefix=COMMONIR --check-prefix=CONSTRAINED %s
5 // RUN: %clang_cc1 -flax-vector-conversions=none -fms-compatibility -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +avx512f -ffp-exception-behavior=maytrap -DSTRICT=1 -emit-llvm -o - -Wall -Werror | FileCheck --check-prefix=COMMON --check-prefix=COMMONIR --check-prefix=CONSTRAINED %s
6 // RUN: %clang_cc1 -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 -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +avx512f -ffp-exception-behavior=maytrap -DSTRICT=1 -S -o - -Wall -Werror | FileCheck --check-prefix=COMMON --check-prefix=CHECK-ASM %s
9 #ifdef STRICT
10 // Test that the constrained intrinsics are picking up the exception
11 // metadata from the AST instead of the global default from the command line.
13 #pragma float_control(except, on)
14 #endif
16 #include <immintrin.h>
18 __m512d test_mm512_sqrt_pd(__m512d a)
20 // COMMON-LABEL: test_mm512_sqrt_pd
21 // UNCONSTRAINED: call <8 x double> @llvm.sqrt.v8f64(<8 x double> %{{.*}})
22 // CONSTRAINED: call <8 x double> @llvm.experimental.constrained.sqrt.v8f64(<8 x double> %{{.*}}, metadata !{{.*}})
23 // CHECK-ASM: vsqrtpd
24 return _mm512_sqrt_pd(a);
27 __m512d test_mm512_mask_sqrt_pd (__m512d __W, __mmask8 __U, __m512d __A)
29 // COMMON-LABEL: test_mm512_mask_sqrt_pd
30 // UNCONSTRAINED: call <8 x double> @llvm.sqrt.v8f64(<8 x double> %{{.*}})
31 // CONSTRAINED: call <8 x double> @llvm.experimental.constrained.sqrt.v8f64(<8 x double> %{{.*}}, metadata !{{.*}})
32 // CHECK-ASM: vsqrtpd
33 // COMMONIR: bitcast i8 %{{.*}} to <8 x i1>
34 // COMMONIR: select <8 x i1> %{{.*}}, <8 x double> %{{.*}}, <8 x double> %{{.*}}
35 return _mm512_mask_sqrt_pd (__W,__U,__A);
38 __m512d test_mm512_maskz_sqrt_pd (__mmask8 __U, __m512d __A)
40 // COMMON-LABEL: test_mm512_maskz_sqrt_pd
41 // UNCONSTRAINED: call <8 x double> @llvm.sqrt.v8f64(<8 x double> %{{.*}})
42 // CONSTRAINED: call <8 x double> @llvm.experimental.constrained.sqrt.v8f64(<8 x double> %{{.*}}, metadata !{{.*}})
43 // CHECK-ASM: vsqrtpd
44 // COMMONIR: bitcast i8 %{{.*}} to <8 x i1>
45 // COMMONIR: select <8 x i1> %{{.*}}, <8 x double> %{{.*}}, <8 x double> {{.*}}
46 return _mm512_maskz_sqrt_pd (__U,__A);
49 __m512 test_mm512_sqrt_ps(__m512 a)
51 // COMMON-LABEL: test_mm512_sqrt_ps
52 // UNCONSTRAINED: call <16 x float> @llvm.sqrt.v16f32(<16 x float> %{{.*}})
53 // CONSTRAINED: call <16 x float> @llvm.experimental.constrained.sqrt.v16f32(<16 x float> %{{.*}}, metadata !{{.*}})
54 // CHECK-ASM: vsqrtps
55 return _mm512_sqrt_ps(a);
58 __m512 test_mm512_mask_sqrt_ps(__m512 __W, __mmask16 __U, __m512 __A)
60 // COMMON-LABEL: test_mm512_mask_sqrt_ps
61 // UNCONSTRAINED: call <16 x float> @llvm.sqrt.v16f32(<16 x float> %{{.*}})
62 // CONSTRAINED: call <16 x float> @llvm.experimental.constrained.sqrt.v16f32(<16 x float> %{{.*}}, metadata !{{.*}})
63 // CHECK-ASM: vsqrtps
64 // COMMONIR: bitcast i16 %{{.*}} to <16 x i1>
65 // COMMONIR: select <16 x i1> %{{.*}}, <16 x float> %{{.*}}, <16 x float> %{{.*}}
66 return _mm512_mask_sqrt_ps( __W, __U, __A);
69 __m512 test_mm512_maskz_sqrt_ps( __mmask16 __U, __m512 __A)
71 // COMMON-LABEL: test_mm512_maskz_sqrt_ps
72 // UNCONSTRAINED: call <16 x float> @llvm.sqrt.v16f32(<16 x float> %{{.*}})
73 // CONSTRAINED: call <16 x float> @llvm.experimental.constrained.sqrt.v16f32(<16 x float> %{{.*}}, metadata !{{.*}})
74 // CHECK-ASM: vsqrtps
75 // COMMONIR: bitcast i16 %{{.*}} to <16 x i1>
76 // COMMONIR: select <16 x i1> %{{.*}}, <16 x float> %{{.*}}, <16 x float> {{.*}}
77 return _mm512_maskz_sqrt_ps(__U ,__A);
80 __m256i test_mm512_cvt_roundps_ph(__m512 __A)
82 // COMMON-LABEL: test_mm512_cvt_roundps_ph
83 // COMMONIR: @llvm.x86.avx512.mask.vcvtps2ph.512
84 return _mm512_cvt_roundps_ph(__A, _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC);
87 __m256i test_mm512_mask_cvt_roundps_ph(__m256i __W , __mmask16 __U, __m512 __A)
89 // COMMON-LABEL: test_mm512_mask_cvt_roundps_ph
90 // COMMONIR: @llvm.x86.avx512.mask.vcvtps2ph.512
91 return _mm512_mask_cvt_roundps_ph(__W, __U, __A, _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC);
94 __m256i test_mm512_maskz_cvt_roundps_ph(__mmask16 __U, __m512 __A)
96 // COMMON-LABEL: test_mm512_maskz_cvt_roundps_ph
97 // COMMONIR: @llvm.x86.avx512.mask.vcvtps2ph.512
98 return _mm512_maskz_cvt_roundps_ph(__U, __A, _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC);
101 __m512 test_mm512_cvt_roundph_ps(__m256i __A)
103 // COMMON-LABEL: test_mm512_cvt_roundph_ps
104 // COMMONIR: @llvm.x86.avx512.mask.vcvtph2ps.512
105 return _mm512_cvt_roundph_ps(__A, _MM_FROUND_NO_EXC);
108 __m512 test_mm512_mask_cvt_roundph_ps(__m512 __W, __mmask16 __U, __m256i __A)
110 // COMMON-LABEL: test_mm512_mask_cvt_roundph_ps
111 // COMMONIR: @llvm.x86.avx512.mask.vcvtph2ps.512
112 return _mm512_mask_cvt_roundph_ps(__W, __U, __A, _MM_FROUND_NO_EXC);
115 __m512 test_mm512_maskz_cvt_roundph_ps(__mmask16 __U, __m256i __A)
117 // COMMON-LABEL: test_mm512_maskz_cvt_roundph_ps
118 // COMMONIR: @llvm.x86.avx512.mask.vcvtph2ps.512
119 return _mm512_maskz_cvt_roundph_ps(__U, __A, _MM_FROUND_NO_EXC);
122 __m128d test_mm_mask_sqrt_sd(__m128d __W, __mmask8 __U, __m128d __A, __m128d __B){
123 // COMMON-LABEL: test_mm_mask_sqrt_sd
124 // COMMONIR: extractelement <2 x double> %{{.*}}, i64 0
125 // UNCONSTRAINED-NEXT: call double @llvm.sqrt.f64(double %{{.*}})
126 // CONSTRAINED-NEXT: call double @llvm.experimental.constrained.sqrt.f64(double %{{.*}}, metadata !{{.*}})
127 // CHECK-ASM: vsqrtsd
128 // COMMONIR-NEXT: extractelement <2 x double> %{{.*}}, i64 0
129 // COMMONIR-NEXT: bitcast i8 %{{.*}} to <8 x i1>
130 // COMMONIR-NEXT: extractelement <8 x i1> %{{.*}}, i64 0
131 // COMMONIR-NEXT: select i1 {{.*}}, double {{.*}}, double {{.*}}
132 // COMMONIR-NEXT: insertelement <2 x double> %{{.*}}, double {{.*}}, i64 0
133 return _mm_mask_sqrt_sd(__W,__U,__A,__B);
136 __m128d test_mm_maskz_sqrt_sd(__mmask8 __U, __m128d __A, __m128d __B){
137 // COMMON-LABEL: test_mm_maskz_sqrt_sd
138 // COMMONIR: extractelement <2 x double> %{{.*}}, i64 0
139 // UNCONSTRAINED-NEXT: call double @llvm.sqrt.f64(double %{{.*}})
140 // CONSTRAINED-NEXT: call double @llvm.experimental.constrained.sqrt.f64(double %{{.*}}, metadata !{{.*}})
141 // CHECK-ASM: vsqrtsd
142 // COMMONIR-NEXT: extractelement <2 x double> %{{.*}}, i64 0
143 // COMMONIR-NEXT: bitcast i8 %{{.*}} to <8 x i1>
144 // COMMONIR-NEXT: extractelement <8 x i1> %{{.*}}, i64 0
145 // COMMONIR-NEXT: select i1 {{.*}}, double {{.*}}, double {{.*}}
146 // COMMONIR-NEXT: insertelement <2 x double> %{{.*}}, double {{.*}}, i64 0
147 return _mm_maskz_sqrt_sd(__U,__A,__B);
150 __m128 test_mm_mask_sqrt_ss(__m128 __W, __mmask8 __U, __m128 __A, __m128 __B){
151 // COMMON-LABEL: test_mm_mask_sqrt_ss
152 // COMMONIR: extractelement <4 x float> %{{.*}}, i64 0
153 // UNCONSTRAINED-NEXT: call float @llvm.sqrt.f32(float %{{.*}})
154 // CONSTRAINED-NEXT: call float @llvm.experimental.constrained.sqrt.f32(float %{{.*}}, metadata !{{.*}})
155 // CHECK-ASM: vsqrtss
156 // COMMONIR-NEXT: extractelement <4 x float> %{{.*}}, i64 0
157 // COMMONIR-NEXT: bitcast i8 %{{.*}} to <8 x i1>
158 // COMMONIR-NEXT: extractelement <8 x i1> %{{.*}}, i64 0
159 // COMMONIR-NEXT: select i1 {{.*}}, float {{.*}}, float {{.*}}
160 // COMMONIR-NEXT: insertelement <4 x float> %{{.*}}, float {{.*}}, i64 0
161 return _mm_mask_sqrt_ss(__W,__U,__A,__B);
164 __m128 test_mm_maskz_sqrt_ss(__mmask8 __U, __m128 __A, __m128 __B){
165 // COMMON-LABEL: test_mm_maskz_sqrt_ss
166 // COMMONIR: extractelement <4 x float> %{{.*}}, i64 0
167 // UNCONSTRAINED-NEXT: call float @llvm.sqrt.f32(float %{{.*}})
168 // CONSTRAINED-NEXT: call float @llvm.experimental.constrained.sqrt.f32(float %{{.*}}, metadata !{{.*}})
169 // CHECK-ASM: vsqrtss
170 // COMMONIR-NEXT: extractelement <4 x float> %{{.*}}, i64 0
171 // COMMONIR-NEXT: bitcast i8 %{{.*}} to <8 x i1>
172 // COMMONIR-NEXT: extractelement <8 x i1> %{{.*}}, i64 0
173 // COMMONIR-NEXT: select i1 {{.*}}, float {{.*}}, float {{.*}}
174 // COMMONIR-NEXT: insertelement <4 x float> %{{.*}}, float {{.*}}, i64 0
175 return _mm_maskz_sqrt_ss(__U,__A,__B);
178 __m512 test_mm512_cvtph_ps (__m256i __A)
180 // COMMON-LABEL: test_mm512_cvtph_ps
181 // COMMONIR: bitcast <4 x i64> %{{.*}} to <16 x i16>
182 // COMMONIR: bitcast <16 x i16> %{{.*}} to <16 x half>
183 // UNCONSTRAINED: fpext <16 x half> %{{.*}} to <16 x float>
184 // CONSTRAINED: call <16 x float> @llvm.experimental.constrained.fpext.v16f32.v16f16(<16 x half> %{{.*}}, metadata !"fpexcept.strict")
185 return _mm512_cvtph_ps (__A);
188 __m512 test_mm512_mask_cvtph_ps (__m512 __W, __mmask16 __U, __m256i __A)
190 // COMMON-LABEL: test_mm512_mask_cvtph_ps
191 // COMMONIR: bitcast <4 x i64> %{{.*}} to <16 x i16>
192 // COMMONIR: bitcast <16 x i16> %{{.*}} to <16 x half>
193 // UNCONSTRAINED: fpext <16 x half> %{{.*}} to <16 x float>
194 // CONSTRAINED: call <16 x float> @llvm.experimental.constrained.fpext.v16f32.v16f16(<16 x half> %{{.*}}, metadata !"fpexcept.strict")
195 // COMMONIR: select <16 x i1> %{{.*}}, <16 x float> %{{.*}}, <16 x float> %{{.*}}
196 return _mm512_mask_cvtph_ps (__W,__U,__A);
199 __m512 test_mm512_maskz_cvtph_ps (__mmask16 __U, __m256i __A)
201 // COMMON-LABEL: test_mm512_maskz_cvtph_ps
202 // COMMONIR: bitcast <4 x i64> %{{.*}} to <16 x i16>
203 // COMMONIR: bitcast <16 x i16> %{{.*}} to <16 x half>
204 // UNCONSTRAINED: fpext <16 x half> %{{.*}} to <16 x float>
205 // CONSTRAINED: call <16 x float> @llvm.experimental.constrained.fpext.v16f32.v16f16(<16 x half> %{{.*}}, metadata !"fpexcept.strict")
206 // COMMONIR: select <16 x i1> %{{.*}}, <16 x float> %{{.*}}, <16 x float> %{{.*}}
207 return _mm512_maskz_cvtph_ps (__U,__A);