Debian Codegraph @

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

raw
1 // RUN: %clang_cc1 -std=c++20 -ffreestanding -fexperimental-new-constant-interpreter -triple x86_64-unknown-unknown -target-feature +sse2 -verify %s
2
3 #include <immintrin.h>
4 #include "../CodeGen/X86/builtin_test_helpers.h"
5
6 namespace Test_mm_cvtsd_ss {
7 namespace OK {
8 constexpr __m128 a = { 9.0f, 5.0f, 6.0f, 7.0f };
9 constexpr __m128d b = { -1.0, 42.0 };
10 TEST_CONSTEXPR(match_m128(_mm_cvtsd_ss(a, b), -1.0f, 5.0f, 6.0f, 7.0f));
11 }
12 namespace Inexact {
13 constexpr __m128 a = { 0.0f, 1.0f, 2.0f, 3.0f };
14 constexpr __m128d b = { 1.0000000000000002, 0.0 };
15 constexpr __m128 r = _mm_cvtsd_ss(a, b);
16 // expected-error@-1 {{must be initialized by a constant expression}}
17 // [email protected]:* {{compile time floating point arithmetic suppressed in strict evaluation modes}}
18 // expected-note@-3 {{in call to '_mm_cvtsd_ss({0.000000e+00, 1.000000e+00, 2.000000e+00, 3.000000e+00}, {1.000000e+00, 0.000000e+00})'}}
19 }
20 namespace Inf {
21 constexpr __m128 a = { 0.0f, 1.0f, 2.0f, 3.0f };
22 constexpr __m128d b = { __builtin_huge_val(), 0.0 };
23 constexpr __m128 r = _mm_cvtsd_ss(a, b);
24 // expected-error@-1 {{must be initialized by a constant expression}}
25 // [email protected]:* {{floating point arithmetic produces an infinity}}
26 // expected-note@-3 {{in call to '_mm_cvtsd_ss({0.000000e+00, 1.000000e+00, 2.000000e+00, 3.000000e+00}, {INF, 0.000000e+00})'}}
27 }
28 namespace NaN {
29 constexpr __m128 a = { 0.0f, 1.0f, 2.0f, 3.0f };
30 constexpr __m128d b = { __builtin_nan(""), 0.0 };
31 constexpr __m128 r = _mm_cvtsd_ss(a, b);
32 // expected-error@-1 {{must be initialized by a constant expression}}
33 // [email protected]:* {{floating point arithmetic produces a NaN}}
34 // expected-note@-3 {{in call to '_mm_cvtsd_ss({0.000000e+00, 1.000000e+00, 2.000000e+00, 3.000000e+00}, {nan, 0.000000e+00})'}}
35 }
36 namespace Subnormal {
37 constexpr __m128 a = { 0.0f, 1.0f, 2.0f, 3.0f };
38 constexpr __m128d b = { 1e-310, 0.0 };
39 constexpr __m128 r = _mm_cvtsd_ss(a, b);
40 // expected-error@-1 {{must be initialized by a constant expression}}
41 // [email protected]:* {{compile time floating point arithmetic suppressed in strict evaluation modes}}
42 // expected-note@-3 {{in call to '_mm_cvtsd_ss({0.000000e+00, 1.000000e+00, 2.000000e+00, 3.000000e+00}, {1.000000e-310, 0.000000e+00})'}}
43 }
44 }
45
46 namespace Test_mm_cvtpd_ps {
47 namespace OK {
48 constexpr __m128d a = { -1.0, +2.0 };
49 TEST_CONSTEXPR(match_m128(_mm_cvtpd_ps(a), -1.0f, +2.0f, 0.0f, 0.0f));
50 }
51 namespace Inexact {
52 constexpr __m128d a = { 1.0000000000000002, 0.0 };
53 constexpr __m128 r = _mm_cvtpd_ps(a);
54 // expected-error@-1 {{must be initialized by a constant expression}}
55 // [email protected]:* {{compile time floating point arithmetic suppressed in strict evaluation modes}}
56 // expected-note@-3 {{in call to '_mm_cvtpd_ps({1.000000e+00, 0.000000e+00})'}}
57 }
58 namespace Inf {
59 constexpr __m128d a = { __builtin_huge_val(), 0.0 };
60 constexpr __m128 r = _mm_cvtpd_ps(a);
61 // expected-error@-1 {{must be initialized by a constant expression}}
62 // [email protected]:* {{floating point arithmetic produces an infinity}}
63 // expected-note@-3 {{in call to '_mm_cvtpd_ps({INF, 0.000000e+00})'}}
64 }
65 namespace NaN {
66 constexpr __m128d a = { __builtin_nan(""), 0.0 };
67 constexpr __m128 r = _mm_cvtpd_ps(a);
68 // expected-error@-1 {{must be initialized by a constant expression}}
69 // [email protected]:* {{floating point arithmetic produces a NaN}}
70 // expected-note@-3 {{in call to '_mm_cvtpd_ps({nan, 0.000000e+00})'}}
71 }
72 namespace Subnormal {
73 constexpr __m128d a = { 1e-310, 0.0 };
74 constexpr __m128 r = _mm_cvtpd_ps(a);
75 // expected-error@-1 {{must be initialized by a constant expression}}
76 // [email protected]:* {{compile time floating point arithmetic suppressed in strict evaluation modes}}
77 // expected-note@-3 {{in call to '_mm_cvtpd_ps({1.000000e-310, 0.000000e+00})'}}
78 }
79 }