Skip to content

Commit

Permalink
Use (better) guard for IEC559 code and constants
Browse files Browse the repository at this point in the history
Clang doesn't defined __GCC_IEC_559, so we need to look at
__STDC_IEC_559__. This is already implemented as COMPLETE_IEC559_SUPPORT
in test_values.h, which we can reuse in the tests. For completeness,
don't define named constants when their use is #ifdef'ed out.

ChangeLog:

	* testsuite/tests/fpclassify.cc: Guard IEC559 special values
	with COMPLETE_IEC559_SUPPORT.
	* testsuite/tests/frexp.cc: Likewise.
  • Loading branch information
mattkretz committed Nov 1, 2023
1 parent 927bd87 commit acbae98
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion testsuite/tests/fpclassify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,16 @@ template <typename V>
{
using T = typename V::value_type;
using intv = std::experimental::fixed_size_simd<int, V::size()>;
#if COMPLETE_IEC559_SUPPORT
constexpr T inf = vir::infinity_v<T>;
constexpr T denorm_min = vir::infinity_v<T>;
constexpr T nan = vir::quiet_NaN_v<T>;
#endif
constexpr T max = vir::finite_max_v<T>;
constexpr T norm_min = vir::norm_min_v<T>;
test_values<V>(
{0., 1., -1.,
#if __GCC_IEC_559 >= 2
#if COMPLETE_IEC559_SUPPORT
-0., inf, -inf, denorm_min, -denorm_min, nan,
norm_min * 0.9, -norm_min * 0.9,
#endif
Expand Down
8 changes: 5 additions & 3 deletions testsuite/tests/frexp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,19 @@ template <typename V>
{
using int_v = std::experimental::fixed_size_simd<int, V::size()>;
using T = typename V::value_type;
#if COMPLETE_IEC559_SUPPORT
constexpr auto denorm_min = vir::denorm_min_v<T>;
constexpr auto norm_min = vir::norm_min_v<T>;
constexpr auto max = vir::finite_max_v<T>;
constexpr auto nan = vir::quiet_NaN_v<T>;
constexpr auto inf = vir::infinity_v<T>;
#endif
constexpr auto max = vir::finite_max_v<T>;
test_values<V>(
{0, 0.25, 0.5, 1, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 32, 31, -0., -0.25, -0.5, -1,
-3, -4, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18,
-19, -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, -32, -31,
#if __GCC_IEC_559 >= 2
#if COMPLETE_IEC559_SUPPORT
denorm_min, -denorm_min, norm_min / 2, -norm_min / 2,
#endif
max, -max, max * 0.123f, -max * 0.123f},
Expand All @@ -53,7 +55,7 @@ template <typename V>
COMPARE(exponent, expectedExponent)
<< "\ninput: " << input << ", fraction: " << fraction;
});
#ifdef __STDC_IEC_559__
#if COMPLETE_IEC559_SUPPORT
test_values<V>(
// If x is a NaN, a NaN is returned, and the value of *exp is unspecified.
//
Expand Down

0 comments on commit acbae98

Please sign in to comment.