]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/experimental/simd/tests/remqo.cc
1 // Copyright (C) 2020-2023 Free Software Foundation, Inc.
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)
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.
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/>.
18 // only: float|double|ldouble * * *
19 // expensive: * [1-9] * *
20 #include "bits/verify.h"
21 #include "bits/metahelpers.h"
22 #include "bits/test_values.h"
28 vir::test::setFuzzyness
<float>(0);
29 vir::test::setFuzzyness
<double>(0);
31 using T
= typename
V::value_type
;
34 #ifdef __STDC_IEC_559__
35 std::__quiet_NaN_v
<T
>, std::__infinity_v
<T
>, -std::__infinity_v
<T
>,
36 std::__denorm_min_v
<T
>, std::__norm_min_v
<T
> / 3, -0.,
38 +0., std::__norm_min_v
<T
>, std::__finite_max_v
<T
>},
39 {10000}, [](V a
, V b
) {
41 #ifndef __STDC_IEC_559__
42 // without __STDC_IEC_559__, remquo(a, 0) is unspecified
45 using IV
= std::experimental::fixed_size_simd
<int, V::size()>;
47 const V totest
= remquo(a
, b
, &quo
);
49 = [&](const auto& v
, const auto& w
) -> std::pair
<const V
, const IV
> {
50 std::pair
<V
, IV
> tmp
= {};
52 for (std::size_t i
= 0; i
< V::size(); ++i
)
55 tmp
.first
[i
] = remquo(v
[i
], w
[i
], &tmp2
);
60 const auto expect1
= expected(a
, b
);
61 COMPARE(isnan(totest
), isnan(expect1
.first
))
62 << "remquo(" << a
<< ", " << b
<< ", quo) = " << totest
63 << " != " << expect1
.first
;
64 const V clean_a
= iif(isnan(totest
), 0, a
);
65 const V clean_b
= iif(isnan(totest
), 1, b
);
66 const auto expect2
= expected(clean_a
, clean_b
);
67 COMPARE(remquo(clean_a
, clean_b
, &quo
), expect2
.first
)
68 << "\nclean_a/b = " << clean_a
<< ", " << clean_b
;
69 COMPARE(quo
, expect2
.second
);