]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/experimental/simd/tests/math_1arg.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / experimental / simd / tests / math_1arg.cc
CommitLineData
7adcbafe 1// Copyright (C) 2020-2022 Free Software Foundation, Inc.
02e32295
MK
2//
3// This file is part of the GNU ISO C++ Library. This library is free
4// software; you can redistribute it and/or modify it under the
5// terms of the GNU General Public License as published by the
6// Free Software Foundation; either version 3, or (at your option)
7// any later version.
8//
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License along
15// with this library; see the file COPYING3. If not see
16// <http://www.gnu.org/licenses/>.
17
aa89c53c
MK
18// only: float|double|ldouble * * *
19// expensive: * [1-9] * *
02e32295
MK
20#include "bits/verify.h"
21#include "bits/test_values.h"
22
23template <typename V>
24 void
25 test()
26 {
27 vir::test::setFuzzyness<float>(0);
28 vir::test::setFuzzyness<double>(0);
29
30 using T = typename V::value_type;
31 constexpr T inf = std::__infinity_v<T>;
32 constexpr T nan = std::__quiet_NaN_v<T>;
33 constexpr T denorm_min = std::__denorm_min_v<T>;
34 constexpr T norm_min = std::__norm_min_v<T>;
35 constexpr T max = std::__finite_max_v<T>;
36#if defined __LONG_DOUBLE_IBM128__
37 // On POWER with IBM128 long double, 1+eps and 2-eps is not a constant
38 // expression. Until this is fixed, just use const instead of constexpr.
39 // (error: '(1.0e+0l + 4.94065645841246544176568792868221e-324l)' is not a
40 // constant expression)
41 const T after_one = 1 + std::__epsilon_v<T>;
42 const T before_one = (2 - std::__epsilon_v<T>) / 2;
43#else
44 constexpr T after_one = 1 + std::__epsilon_v<T>;
45 constexpr T before_one = (2 - std::__epsilon_v<T>) / 2;
46#endif
47 const std::initializer_list<T>
48 input_values = {+0.,
49 0.5,
50 -0.5,
51 before_one,
52 -before_one,
53 after_one,
54 -after_one,
55 1.5,
56 -1.5,
57 2 * before_one,
58 -2 * before_one,
59 2 * after_one,
60 -2 * after_one,
61 2.5,
62 -2.5,
63 0x1.fffffffffffffp52,
64 -0x1.fffffffffffffp52,
65 0x1.ffffffffffffep52,
66 -0x1.ffffffffffffep52,
67 0x1.ffffffffffffdp52,
68 -0x1.ffffffffffffdp52,
69 0x1.fffffep21,
70 -0x1.fffffep21,
71 0x1.fffffcp21,
72 -0x1.fffffcp21,
73 0x1.fffffep22,
74 -0x1.fffffep22,
75 0x1.fffffcp22,
76 -0x1.fffffcp22,
77 0x1.fffffep23,
78 -0x1.fffffep23,
79 0x1.fffffcp23,
80 -0x1.fffffcp23,
81 0x1.8p23,
82 -0x1.8p23,
83 inf,
84 -inf,
85 -0.,
86 nan,
87 denorm_min,
88 norm_min / 3,
89 norm_min,
90 max};
91 test_values<V>(input_values, {10000}, MAKE_TESTER(erf), MAKE_TESTER(erfc),
92 MAKE_TESTER(tgamma), MAKE_TESTER(lgamma), MAKE_TESTER(ceil),
93 MAKE_TESTER(floor), MAKE_TESTER(trunc), MAKE_TESTER(round),
94 MAKE_TESTER(lround), MAKE_TESTER(llround),
95 MAKE_TESTER(nearbyint), MAKE_TESTER(rint), MAKE_TESTER(lrint),
96 MAKE_TESTER(llrint), MAKE_TESTER(ilogb));
97
98 // sqrt(x) on x87 is precise in 80 bits, but the subsequent rounding can be
99 // wrong (up to 1 ULP)
100#if __FLT_EVAL_METHOD__ == 1
101 vir::test::setFuzzyness<float>(1);
102 vir::test::setFuzzyness<double>(0);
103#elif __FLT_EVAL_METHOD__ == 2
104 vir::test::setFuzzyness<float>(1);
105 vir::test::setFuzzyness<double>(1);
106#endif
107 test_values<V>(input_values, {10000}, MAKE_TESTER(sqrt));
108 }