Debian Codegraph @

clang/test/SemaCXX/constexpr-x86-avx512f-builtins.cpp

raw
1 // RUN: %clang_cc1 -std=c++20 -ffreestanding -fexperimental-new-constant-interpreter -triple x86_64-unknown-unknown -target-feature +avx512f -verify %s
2
3 #include <immintrin.h>
4 #include "../CodeGen/X86/builtin_test_helpers.h"
5
6 namespace Test_mm_mask_cvtsd_ss {
7 namespace OK {
8 constexpr __m128 src = { 9.0f, 5.0f, 6.0f, 7.0f };
9 constexpr __m128 a = { 1.0f, 2.0f, 3.0f, 4.0f };
10 constexpr __m128d b = { -1.0, 42.0 };
11 TEST_CONSTEXPR(match_m128(_mm_mask_cvtsd_ss(src, 0x1, a, b), -1.0f, 2.0f, 3.0f, 4.0f));
12 }
13 namespace MaskOff {
14 constexpr __m128 src = { 9.0f, 5.0f, 6.0f, 7.0f };
15 constexpr __m128 a = { 1.0f, 2.0f, 3.0f, 4.0f };
16 constexpr __m128d b = { -1.0, 42.0 };
17 TEST_CONSTEXPR(match_m128(_mm_mask_cvtsd_ss(src, 0x0, a, b), 9.0f, 2.0f, 3.0f, 4.0f));
18 }
19 namespace MaskOffInexact {
20 constexpr __m128 src = { 9.0f, 5.0f, 6.0f, 7.0f };
21 constexpr __m128 a = { 1.0f, 2.0f, 3.0f, 4.0f };
22 constexpr __m128d b_inexact = { 1.0000000000000002, 0.0 };
23 constexpr __m128 r = _mm_mask_cvtsd_ss(src, 0x0, a, b_inexact);
24 TEST_CONSTEXPR(match_m128(r, 9.0f, 2.0f, 3.0f, 4.0f));
25 }
26 namespace MaskOnInexact {
27 constexpr __m128 src = { 9.0f, 5.0f, 6.0f, 7.0f };
28 constexpr __m128 a = { 1.0f, 2.0f, 3.0f, 4.0f };
29 constexpr __m128d b_inexact = { 1.0000000000000002, 0.0 };
30 constexpr __m128 r = _mm_mask_cvtsd_ss(src, 0x1, a, b_inexact);
31 // expected-error@-1 {{must be initialized by a constant expression}}
32 // [email protected]:* {{compile time floating point arithmetic suppressed in strict evaluation modes}}
33 // expected-note@-3 {{in call to '_mm_mask_cvtsd_ss({9.000000e+00, 5.000000e+00, 6.000000e+00, 7.000000e+00}, 1, {1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00}, {1.000000e+00, 0.000000e+00})'}}
34 }
35 namespace MaskOnInf {
36 constexpr __m128 src = { 9.0f, 5.0f, 6.0f, 7.0f };
37 constexpr __m128 a = { 1.0f, 2.0f, 3.0f, 4.0f };
38 constexpr __m128d b_inf = { __builtin_huge_val(), 0.0 };
39 constexpr __m128 r = _mm_mask_cvtsd_ss(src, 0x1, a, b_inf);
40 // expected-error@-1 {{must be initialized by a constant expression}}
41 // [email protected]:* {{floating point arithmetic produces an infinity}}
42 // expected-note@-3 {{in call to '_mm_mask_cvtsd_ss({9.000000e+00, 5.000000e+00, 6.000000e+00, 7.000000e+00}, 1, {1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00}, {INF, 0.000000e+00})'}}
43 }
44 namespace MaskOnNaN {
45 constexpr __m128 src = { 9.0f, 5.0f, 6.0f, 7.0f };
46 constexpr __m128 a = { 1.0f, 2.0f, 3.0f, 4.0f };
47 constexpr __m128d b_nan = { __builtin_nan(""), 0.0 };
48 constexpr __m128 r = _mm_mask_cvtsd_ss(src, 0x1, a, b_nan);
49 // expected-error@-1 {{must be initialized by a constant expression}}
50 // [email protected]:* {{floating point arithmetic produces a NaN}}
51 // expected-note@-3 {{in call to '_mm_mask_cvtsd_ss({9.000000e+00, 5.000000e+00, 6.000000e+00, 7.000000e+00}, 1, {1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00}, {nan, 0.000000e+00})'}}
52 }
53 namespace MaskOnSubnormal {
54 constexpr __m128 src = { 9.0f, 5.0f, 6.0f, 7.0f };
55 constexpr __m128 a = { 1.0f, 2.0f, 3.0f, 4.0f };
56 constexpr __m128d b_sub = { 1e-310, 0.0 };
57 constexpr __m128 r = _mm_mask_cvtsd_ss(src, 0x1, a, b_sub);
58 // expected-error@-1 {{must be initialized by a constant expression}}
59 // [email protected]:* {{compile time floating point arithmetic suppressed in strict evaluation modes}}
60 // expected-note@-3 {{in call to '_mm_mask_cvtsd_ss({9.000000e+00, 5.000000e+00, 6.000000e+00, 7.000000e+00}, 1, {1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00}, {1.000000e-310, 0.000000e+00})'}}
61 }
62 }
63
64 namespace Test_mm_maskz_cvtsd_ss {
65 namespace OK {
66 constexpr __m128 a = { 1.0f, 2.0f, 3.0f, 4.0f };
67 constexpr __m128d b = { -1.0, 42.0 };
68 TEST_CONSTEXPR(match_m128(_mm_maskz_cvtsd_ss(0x1, a, b), -1.0f, 2.0f, 3.0f, 4.0f));
69 }
70 namespace MaskOff {
71 constexpr __m128 a = { 1.0f, 2.0f, 3.0f, 4.0f };
72 constexpr __m128d b = { -1.0, 42.0 };
73 TEST_CONSTEXPR(match_m128(_mm_maskz_cvtsd_ss(0x0, a, b), 0.0f, 2.0f, 3.0f, 4.0f));
74 }
75 namespace MaskOffInexact {
76 constexpr __m128 a = { 1.0f, 2.0f, 3.0f, 4.0f };
77 constexpr __m128d b_inexact = { 1.0000000000000002, 0.0 };
78 TEST_CONSTEXPR(match_m128(_mm_maskz_cvtsd_ss(0x0, a, b_inexact), 0.0f, 2.0f, 3.0f, 4.0f));
79 }
80 namespace MaskOnInf {
81 constexpr __m128 a = { 1.0f, 2.0f, 3.0f, 4.0f };
82 constexpr __m128d b_inf = { __builtin_huge_val(), 0.0 };
83 constexpr __m128 r = _mm_maskz_cvtsd_ss(0x1, a, b_inf);
84 // expected-error@-1 {{must be initialized by a constant expression}}
85 // [email protected]:* {{floating point arithmetic produces an infinity}}
86 // expected-note@-3 {{in call to '_mm_maskz_cvtsd_ss(1, {1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00}, {INF, 0.000000e+00})'}}
87 }
88 namespace MaskOnNaN {
89 constexpr __m128 a = { 1.0f, 2.0f, 3.0f, 4.0f };
90 constexpr __m128d b_nan = { __builtin_nan(""), 0.0 };
91 constexpr __m128 r = _mm_maskz_cvtsd_ss(0x1, a, b_nan);
92 // expected-error@-1 {{must be initialized by a constant expression}}
93 // [email protected]:* {{floating point arithmetic produces a NaN}}
94 // expected-note@-3 {{in call to '_mm_maskz_cvtsd_ss(1, {1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00}, {nan, 0.000000e+00})'}}
95 }
96 }
97
98 namespace Test_mm512_cvtpd_ps {
99 namespace OK {
100 constexpr __m512d a = { -1.0, +2.0, +4.0, +8.0, +16.0, +32.0, +64.0, +128.0 };
101 TEST_CONSTEXPR(match_m256(_mm512_cvtpd_ps(a), -1.0f, +2.0f, +4.0f, +8.0f, +16.0f, +32.0f, +64.0f, +128.0f));
102 }
103 namespace Inexact {
104 constexpr __m512d a = { 1.0000000000000002, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
105 constexpr __m256 r = _mm512_cvtpd_ps(a);
106 // expected-error@-1 {{must be initialized by a constant expression}}
107 // [email protected]:* {{compile time floating point arithmetic suppressed in strict evaluation modes}}
108 // expected-note@-3 {{in call to '_mm512_cvtpd_ps({1.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00})'}}
109 }
110 }
111
112 namespace Test_mm512_mask_cvtpd_ps {
113 namespace OK {
114 constexpr __m256 src = { 9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f };
115 constexpr __m512d a = { -1.0, +2.0, +4.0, +8.0, +16.0, +32.0, +64.0, +128.0 };
116 TEST_CONSTEXPR(match_m256(_mm512_mask_cvtpd_ps(src, 0x05, a), -1.0f, 9.0f, +4.0f, 9.0f, 9.0f, 9.0f, 9.0f, 9.0f));
117 }
118 namespace MaskOffInexact {
119 constexpr __m256 src = { 9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f };
120 constexpr __m512d a_inexact = { -1.0, +2.0, +4.0, +8.0, +16.0, 1.0000000000000002, +64.0, +128.0 };
121 TEST_CONSTEXPR(match_m256(_mm512_mask_cvtpd_ps(src, 0b11011111, a_inexact), -1.0f, +2.0f, +4.0f, +8.0f, +16.0f, 9.0f, +64.0f, +128.0f));
122 }
123 namespace MaskOffInf {
124 constexpr __m256 src = { 9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f };
125 constexpr __m512d a_inf = { -1.0, +2.0, +4.0, +8.0, +16.0, __builtin_huge_val(), +64.0, +128.0 };
126 TEST_CONSTEXPR(match_m256(_mm512_mask_cvtpd_ps(src, 0x1F, a_inf), -1.0f, +2.0f, +4.0f, +8.0f, +16.0f, 9.0f, 9.0f, 9.0f));
127 }
128 namespace MaskOffNaN {
129 constexpr __m256 src = { 9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f };
130 constexpr __m512d a_nan = { -1.0, +2.0, +4.0, +8.0, +16.0, __builtin_nan(""), +64.0, +128.0 };
131 TEST_CONSTEXPR(match_m256(_mm512_mask_cvtpd_ps(src, 0x1F, a_nan), -1.0f, +2.0f, +4.0f, +8.0f, +16.0f, 9.0f, 9.0f, 9.0f));
132 }
133 namespace MaskOnInf {
134 constexpr __m256 src = { 9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f };
135 constexpr __m512d a_inf = { -1.0, +2.0, +4.0, __builtin_huge_val(), +16.0, +32.0, +64.0, +128.0 };
136 constexpr __m256 r = _mm512_mask_cvtpd_ps(src, 0x08, a_inf);
137 // expected-error@-1 {{must be initialized by a constant expression}}
138 // [email protected]:* {{floating point arithmetic produces an infinity}}
139 // expected-note@-3 {{in call to '_mm512_mask_cvtpd_ps({9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00}, 8, {-1.000000e+00, 2.000000e+00, 4.000000e+00, INF, 1.600000e+01, 3.200000e+01, 6.400000e+01, 1.280000e+02})'}}
140 }
141 namespace MaskOnNaN {
142 constexpr __m256 src = { 9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f };
143 constexpr __m512d a_nan = { -1.0, +2.0, +4.0, __builtin_nan(""), +16.0, +32.0, +64.0, +128.0 };
144 constexpr __m256 r = _mm512_mask_cvtpd_ps(src, 0x08, a_nan);
145 // expected-error@-1 {{must be initialized by a constant expression}}
146 // [email protected]:* {{floating point arithmetic produces a NaN}}
147 // expected-note@-3 {{in call to '_mm512_mask_cvtpd_ps({9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00}, 8, {-1.000000e+00, 2.000000e+00, 4.000000e+00, nan, 1.600000e+01, 3.200000e+01, 6.400000e+01, 1.280000e+02})'}}
148 }
149 }
150
151 namespace Test_mm512_maskz_cvtpd_ps {
152 namespace OK {
153 constexpr __m512d a = { -1.0, +2.0, +4.0, +8.0, +16.0, +32.0, +64.0, +128.0 };
154 TEST_CONSTEXPR(match_m256(_mm512_maskz_cvtpd_ps(0x81, a), -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, +128.0f));
155 }
156 namespace MaskOffInexact {
157 constexpr __m512d a_inexact = { -1.0, +2.0, +4.0, +8.0, +16.0, 1.0000000000000002, +64.0, +128.0 };
158 TEST_CONSTEXPR(match_m256(_mm512_maskz_cvtpd_ps(0b11011111, a_inexact), -1.0f, +2.0f, +4.0f, +8.0f, +16.0f, 0.0f, +64.0f, +128.0f));
159 }
160 namespace MaskOffInf {
161 constexpr __m512d a_inf = { -1.0, +2.0, +4.0, +8.0, +16.0, __builtin_huge_val(), +64.0, +128.0 };
162 TEST_CONSTEXPR(match_m256(_mm512_maskz_cvtpd_ps(0x1F, a_inf), -1.0f, +2.0f, +4.0f, +8.0f, +16.0f, 0.0f, 0.0f, 0.0f));
163 }
164 namespace MaskOffNaN {
165 constexpr __m512d a_nan = { -1.0, +2.0, +4.0, +8.0, +16.0, __builtin_nan(""), +64.0, +128.0 };
166 TEST_CONSTEXPR(match_m256(_mm512_maskz_cvtpd_ps(0x1F, a_nan), -1.0f, +2.0f, +4.0f, +8.0f, +16.0f, 0.0f, 0.0f, 0.0f));
167 }
168 namespace MaskOnInf {
169 constexpr __m512d a_inf = { -1.0, +2.0, +4.0, __builtin_huge_val(), +16.0, +32.0, +64.0, +128.0 };
170 constexpr __m256 r = _mm512_maskz_cvtpd_ps(0x08, a_inf);
171 // expected-error@-1 {{must be initialized by a constant expression}}
172 // [email protected]:* {{floating point arithmetic produces an infinity}}
173 // expected-note@-3 {{in call to '_mm512_maskz_cvtpd_ps(8, {-1.000000e+00, 2.000000e+00, 4.000000e+00, INF, 1.600000e+01, 3.200000e+01, 6.400000e+01, 1.280000e+02})'}}
174 }
175 namespace MaskOnNaN {
176 constexpr __m512d a_nan = { -1.0, +2.0, +4.0, __builtin_nan(""), +16.0, +32.0, +64.0, +128.0 };
177 constexpr __m256 r = _mm512_maskz_cvtpd_ps(0x08, a_nan);
178 // expected-error@-1 {{must be initialized by a constant expression}}
179 // [email protected]:* {{floating point arithmetic produces a NaN}}
180 // expected-note@-3 {{in call to '_mm512_maskz_cvtpd_ps(8, {-1.000000e+00, 2.000000e+00, 4.000000e+00, nan, 1.600000e+01, 3.200000e+01, 6.400000e+01, 1.280000e+02})'}}
181 }
182 }
183
184 namespace Test_mm512_cvtpd_pslo {
185 namespace OK {
186 constexpr __m512d a = { -1.0, +2.0, +4.0, +8.0, +16.0, +32.0, +64.0, +128.0 };
187 TEST_CONSTEXPR(match_m512(_mm512_cvtpd_pslo(a), -1.0f, +2.0f, +4.0f, +8.0f, +16.0f, +32.0f, +64.0f, +128.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
188 }
189 }
190
191 namespace Test_mm512_mask_cvtpd_pslo {
192 namespace OK {
193 constexpr __m512 src = (__m512){ 9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,
194 9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f };
195 constexpr __m512d a = { -1.0, +2.0, +4.0, +8.0, +16.0, +32.0, +64.0, +128.0 };
196 TEST_CONSTEXPR(match_m512(_mm512_mask_cvtpd_pslo(src, 0x3, a), -1.0f, +2.0f, 9.0f, 9.0f, 9.0f, 9.0f, 9.0f, 9.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
197 }
198 namespace MaskOffInf {
199 constexpr __m512 src = (__m512){ 9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,
200 9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f };
201 constexpr __m512d a_inf = { -1.0, +2.0, __builtin_huge_val(), +8.0, +16.0, +32.0, +64.0, +128.0 };
202 TEST_CONSTEXPR(match_m512(_mm512_mask_cvtpd_pslo(src, 0x3, a_inf), -1.0f, +2.0f, 9.0f, 9.0f, 9.0f, 9.0f, 9.0f, 9.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
203 }
204 namespace MaskOffNaN {
205 constexpr __m512 src = (__m512){ 9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,
206 9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f };
207 constexpr __m512d a_nan = { -1.0, +2.0, +4.0, __builtin_nan(""), +16.0, +32.0, +64.0, +128.0 };
208 TEST_CONSTEXPR(match_m512(_mm512_mask_cvtpd_pslo(src, 0x7, a_nan), -1.0f, +2.0f, +4.0f, 9.0f, 9.0f, 9.0f, 9.0f, 9.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
209 }
210 namespace MaskOnInf {
211 constexpr __m512 src = (__m512){ 9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,
212 9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f };
213 constexpr __m512d a_inf = { -1.0, +2.0, __builtin_huge_val(), +8.0, +16.0, +32.0, +64.0, +128.0 };
214 constexpr __m512 r = _mm512_mask_cvtpd_pslo(src, 0x4, a_inf);
215 // expected-error@-1 {{must be initialized by a constant expression}}
216 // [email protected]:* {{floating point arithmetic produces an infinity}}
217 // [email protected]:* {{in call to '_mm512_mask_cvtpd_ps({9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00}, 4, {-1.000000e+00, 2.000000e+00, INF, 8.000000e+00, 1.600000e+01, 3.200000e+01, 6.400000e+01, 1.280000e+02})'}}
218 // expected-note@-4 {{in call to '_mm512_mask_cvtpd_pslo({9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00}, 4, {-1.000000e+00, 2.000000e+00, INF, 8.000000e+00, 1.600000e+01, 3.200000e+01, 6.400000e+01, 1.280000e+02})'}}
219 }
220 namespace MaskOnNaN {
221 constexpr __m512 src = (__m512){ 9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,
222 9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f,9.0f };
223 constexpr __m512d a_nan = { -1.0, +2.0, __builtin_nan(""), +8.0, +16.0, +32.0, +64.0, +128.0 };
224 constexpr __m512 r = _mm512_mask_cvtpd_pslo(src, 0x4, a_nan);
225 // expected-error@-1 {{must be initialized by a constant expression}}
226 // [email protected]:* {{floating point arithmetic produces a NaN}}
227 // [email protected]:* {{in call to '_mm512_mask_cvtpd_ps({9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00}, 4, {-1.000000e+00, 2.000000e+00, nan, 8.000000e+00, 1.600000e+01, 3.200000e+01, 6.400000e+01, 1.280000e+02})'}}
228 // expected-note@-4 {{in call to '_mm512_mask_cvtpd_pslo({9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00}, 4, {-1.000000e+00, 2.000000e+00, nan, 8.000000e+00, 1.600000e+01, 3.200000e+01, 6.400000e+01, 1.280000e+02})'}}
229 }
230 }