Debian Codegraph @

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

raw
1 // RUN: %clang_cc1 -std=c++20 -ffreestanding -fexperimental-new-constant-interpreter -triple x86_64-unknown-unknown -target-feature +avx512f -target-feature +avx512vl -verify %s
2
3 #include <immintrin.h>
4 #include "../CodeGen/X86/builtin_test_helpers.h"
5
6 namespace Test_mm_mask_cvtpd_ps {
7 namespace OK {
8 constexpr __m128 src = { 9.0f, 9.0f, 9.0f, 9.0f };
9 constexpr __m128d a = { -1.0, +2.0 };
10 TEST_CONSTEXPR(match_m128(_mm_mask_cvtpd_ps(src, 0x3, a), -1.0f, +2.0f, 9.0f, 9.0f));
11 }
12 namespace Partial {
13 constexpr __m128 src = { 9.0f, 9.0f, 9.0f, 9.0f };
14 constexpr __m128d a = { -1.0, +2.0 };
15 TEST_CONSTEXPR(match_m128(_mm_mask_cvtpd_ps(src, 0x1, a), -1.0f, 9.0f, 9.0f, 9.0f));
16 }
17 namespace MaskOffInexact {
18 constexpr __m128 src = { 9.0f, 9.0f, 9.0f, 9.0f };
19 constexpr __m128d a_inexact = { -1.0, 1.0000000000000002 };
20 TEST_CONSTEXPR(match_m128(_mm_mask_cvtpd_ps(src, 0x1, a_inexact), -1.0f, 9.0f, 9.0f, 9.0f));
21 }
22 namespace MaskOnInexact {
23 constexpr __m128 src = { 9.0f, 9.0f, 9.0f, 9.0f };
24 constexpr __m128d a_inexact = { -1.0, 1.0000000000000002 };
25 constexpr __m128 r = _mm_mask_cvtpd_ps(src, 0x2, a_inexact);
26 // expected-error@-1 {{must be initialized by a constant expression}}
27 // [email protected]:* {{compile time floating point arithmetic suppressed in strict evaluation modes}}
28 // expected-note@-3 {{in call to '_mm_mask_cvtpd_ps({9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00}, 2, {-1.000000e+00, 1.000000e+00})'}}
29 }
30 namespace MaskOnInf {
31 constexpr __m128 src = { 9.0f, 9.0f, 9.0f, 9.0f };
32 constexpr __m128d a_inf = { -1.0, __builtin_huge_val() };
33 constexpr __m128 r = _mm_mask_cvtpd_ps(src, 0x2, a_inf);
34 // expected-error@-1 {{must be initialized by a constant expression}}
35 // [email protected]:* {{floating point arithmetic produces an infinity}}
36 // expected-note@-3 {{in call to '_mm_mask_cvtpd_ps({9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00}, 2, {-1.000000e+00, INF})'}}
37 }
38 namespace MaskOnNaN {
39 constexpr __m128 src = { 9.0f, 9.0f, 9.0f, 9.0f };
40 constexpr __m128d a_nan = { -1.0, __builtin_nan("") };
41 constexpr __m128 r = _mm_mask_cvtpd_ps(src, 0x2, a_nan);
42 // expected-error@-1 {{must be initialized by a constant expression}}
43 // [email protected]:* {{floating point arithmetic produces a NaN}}
44 // expected-note@-3 {{in call to '_mm_mask_cvtpd_ps({9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00}, 2, {-1.000000e+00, nan})'}}
45 }
46 }
47
48 namespace Test_mm_maskz_cvtpd_ps {
49 namespace OK {
50 constexpr __m128d a = { -1.0, +2.0 };
51 TEST_CONSTEXPR(match_m128(_mm_maskz_cvtpd_ps(0x1, a), -1.0f, 0.0f, 0.0f, 0.0f));
52 }
53 namespace MaskOffInexact {
54 constexpr __m128d a_inexact = { -1.0, 1.0000000000000002 };
55 TEST_CONSTEXPR(match_m128(_mm_maskz_cvtpd_ps(0x1, a_inexact), -1.0f, 0.0f, 0.0f, 0.0f));
56 }
57 namespace MaskOnInf {
58 constexpr __m128d a_inf = { -1.0, __builtin_huge_val() };
59 constexpr __m128 r = _mm_maskz_cvtpd_ps(0x2, a_inf);
60 // expected-error@-1 {{must be initialized by a constant expression}}
61 // [email protected]:* {{floating point arithmetic produces an infinity}}
62 // expected-note@-3 {{in call to '_mm_maskz_cvtpd_ps(2, {-1.000000e+00, INF})'}}
63 }
64 namespace MaskOnNaN {
65 constexpr __m128d a_nan = { -1.0, __builtin_nan("") };
66 constexpr __m128 r = _mm_maskz_cvtpd_ps(0x2, a_nan);
67 // expected-error@-1 {{must be initialized by a constant expression}}
68 // [email protected]:* {{floating point arithmetic produces a NaN}}
69 // expected-note@-3 {{in call to '_mm_maskz_cvtpd_ps(2, {-1.000000e+00, nan})'}}
70 }
71 }
72
73 namespace Test_mm256_mask_cvtpd_ps {
74 namespace OK {
75 constexpr __m128 src = { 9.0f, 9.0f, 9.0f, 9.0f };
76 constexpr __m256d a = { 0.0, -1.0, +2.0, +3.5 };
77 TEST_CONSTEXPR(match_m128(_mm256_mask_cvtpd_ps(src, 0xF, a), 0.0f, -1.0f, +2.0f, +3.5f));
78 }
79 namespace MaskOffInf {
80 constexpr __m128 src = { 9.0f, 9.0f, 9.0f, 9.0f };
81 constexpr __m256d a_inf = { -1.0, +2.0, __builtin_huge_val(), +8.0 };
82 constexpr __m128 r = _mm256_mask_cvtpd_ps(src, 0x3, a_inf);
83 // expected-error@-1 {{must be initialized by a constant expression}}
84 // [email protected]:* {{floating point arithmetic produces an infinity}}
85 // [email protected]:* {{in call to '_mm256_cvtpd_ps({-1.000000e+00, 2.000000e+00, INF, 8.000000e+00})'}}
86 // expected-note@-4 {{in call to '_mm256_mask_cvtpd_ps({9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00}, 3, {-1.000000e+00, 2.000000e+00, INF, 8.000000e+00})'}}
87 }
88 namespace MaskOffNaN {
89 constexpr __m128 src = { 9.0f, 9.0f, 9.0f, 9.0f };
90 constexpr __m256d a_nan = { -1.0, +2.0, +4.0, __builtin_nan("") };
91 constexpr __m128 r = _mm256_mask_cvtpd_ps(src, 0x7, a_nan);
92 // expected-error@-1 {{must be initialized by a constant expression}}
93 // [email protected]:* {{floating point arithmetic produces a NaN}}
94 // [email protected]:* {{in call to '_mm256_cvtpd_ps({-1.000000e+00, 2.000000e+00, 4.000000e+00, nan})'}}
95 // expected-note@-4 {{in call to '_mm256_mask_cvtpd_ps({9.000000e+00, 9.000000e+00, 9.000000e+00, 9.000000e+00}, 7, {-1.000000e+00, 2.000000e+00, 4.000000e+00, nan})'}}
96 }
97 }
98
99 namespace Test_mm256_maskz_cvtpd_ps {
100 namespace OK {
101 constexpr __m256d a = { 0.0, -1.0, +2.0, +3.5 };
102 TEST_CONSTEXPR(match_m128(_mm256_maskz_cvtpd_ps(0x5, a), 0.0f, 0.0f, +2.0f, 0.0f));
103 }
104 namespace MaskOffInf {
105 constexpr __m256d a_inf = { -1.0, +2.0, __builtin_huge_val(), +8.0 };
106 constexpr __m128 r = _mm256_maskz_cvtpd_ps(0x3, a_inf);
107 // expected-error@-1 {{must be initialized by a constant expression}}
108 // [email protected]:* {{floating point arithmetic produces an infinity}}
109 // [email protected]:* {{in call to '_mm256_cvtpd_ps({-1.000000e+00, 2.000000e+00, INF, 8.000000e+00})'}}
110 // expected-note@-4 {{in call to '_mm256_maskz_cvtpd_ps(3, {-1.000000e+00, 2.000000e+00, INF, 8.000000e+00})'}}
111 }
112 namespace MaskOffNaN {
113 constexpr __m256d a_nan = { -1.0, +2.0, +4.0, __builtin_nan("") };
114 constexpr __m128 r = _mm256_maskz_cvtpd_ps(0x7, a_nan);
115 // expected-error@-1 {{must be initialized by a constant expression}}
116 // [email protected]:* {{floating point arithmetic produces a NaN}}
117 // [email protected]:* {{in call to '_mm256_cvtpd_ps({-1.000000e+00, 2.000000e+00, 4.000000e+00, nan})'}}
118 // expected-note@-4 {{in call to '_mm256_maskz_cvtpd_ps(7, {-1.000000e+00, 2.000000e+00, 4.000000e+00, nan})'}}
119 }
120 }