]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/experimental/simd/tests/remqo.cc
1 // Copyright (C) 2020-2024 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/main.h"
26 vir::test::setFuzzyness
<float>(0);
27 vir::test::setFuzzyness
<double>(0);
29 using T
= typename
V::value_type
;
32 #ifdef __STDC_IEC_559__
33 std::__quiet_NaN_v
<T
>, std::__infinity_v
<T
>, -std::__infinity_v
<T
>,
34 std::__denorm_min_v
<T
>, std::__norm_min_v
<T
> / 3, -0.,
36 +0., std::__norm_min_v
<T
>, std::__finite_max_v
<T
>},
37 {10000}, [](V a
, V b
) {
39 #ifndef __STDC_IEC_559__
40 // without __STDC_IEC_559__, remquo(a, 0) is unspecified
43 using IV
= std::experimental::fixed_size_simd
<int, V::size()>;
45 const V totest
= remquo(a
, b
, &quo
);
47 = [&](const auto& v
, const auto& w
) -> std::pair
<const V
, const IV
> {
48 std::pair
<V
, IV
> tmp
= {};
50 for (std::size_t i
= 0; i
< V::size(); ++i
)
53 tmp
.first
[i
] = remquo(v
[i
], w
[i
], &tmp2
);
58 const auto expect1
= expected(a
, b
);
59 COMPARE(isnan(totest
), isnan(expect1
.first
))
60 << "remquo(" << a
<< ", " << b
<< ", quo) = " << totest
61 << " != " << expect1
.first
;
62 const V clean_a
= iif(isnan(totest
), 0, a
);
63 const V clean_b
= iif(isnan(totest
), 1, b
);
64 const auto expect2
= expected(clean_a
, clean_b
);
65 COMPARE(remquo(clean_a
, clean_b
, &quo
), expect2
.first
)
66 << "\nclean_a/b = " << clean_a
<< ", " << clean_b
;
67 COMPARE(quo
, expect2
.second
);