[PING][PATCH 2/2] Limit unnormal tests to supported long double formats
Siddhesh Poyarekar
siddhesh@gotplt.org
Tue Jan 12 07:22:33 GMT 2021
On 1/4/21 7:54 PM, Siddhesh Poyarekar via Libc-alpha wrote:
> Use the right argument code (j) in the unnormal tests and prevent
> compilation of the tests in anything other than long double and
> Float64x. Additionally, cast inputs from the
> ieee_long_double_shape_type struct to Float64x to properly test it.
> ---
> math/libm-test-driver.c | 16 +++++++++-------
> math/libm-test-fpclassify.inc | 18 +++++++++---------
> math/libm-test-isinf.inc | 18 +++++++++---------
> math/libm-test-isnan.inc | 18 +++++++++---------
> math/libm-test-issignaling.inc | 18 +++++++++---------
> math/libm-test-support.h | 2 ++
> math/test-float64x.h | 1 +
> math/test-ldouble.h | 1 +
> 8 files changed, 49 insertions(+), 43 deletions(-)
>
> diff --git a/math/libm-test-driver.c b/math/libm-test-driver.c
> index f7c0861c39..6826ffac20 100644
> --- a/math/libm-test-driver.c
> +++ b/math/libm-test-driver.c
> @@ -123,7 +123,7 @@ const char qtype_str[] = TYPE_STR;
> #define snan_value_ld __builtin_nansl ("")
>
> /* For pseudo-normal number tests. */
> -#if TEST_COND_intel96
> +#if TEST_COND_unnormal
> # include <math_ldbl.h>
> #define pseudo_inf { .parts = { 0x00000000, 0x00000000, 0x7fff }}
> #define pseudo_zero { .parts = { 0x00000000, 0x00000000, 0x0100 }}
> @@ -327,8 +327,8 @@ struct test_f_i_data
> } rd, rn, rz, ru;
> };
> /* Used for RUN_TEST_LOOP_f_i_tg_u and RUN_TEST_LOOP_f_b_tg_u. */
> -#if TEST_COND_intel96
> -struct test_f_i_data_u
> +#if TEST_COND_unnormal
> +struct test_j_i_data_u
> {
> const char *arg_str;
> ieee_long_double_shape_type arg;
> @@ -855,17 +855,19 @@ struct test_Ff_b1_data
> (ARRAY)[i].RM_##ROUNDING_MODE.expected, \
> (ARRAY)[i].RM_##ROUNDING_MODE.exceptions); \
> ROUND_RESTORE_ ## ROUNDING_MODE
> -#define RUN_TEST_LOOP_f_b_tg_u(FUNC_NAME, ARRAY, ROUNDING_MODE) \
> +#define RUN_TEST_LOOP_j_b_tg_u(FUNC_NAME, ARRAY, ROUNDING_MODE) \
> IF_ROUND_INIT_ ## ROUNDING_MODE \
> for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++) \
> - RUN_TEST_f_b_tg ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg.value, \
> + RUN_TEST_f_b_tg ((ARRAY)[i].arg_str, FUNC_NAME, \
> + (FLOAT)(ARRAY)[i].arg.value, \
> (ARRAY)[i].RM_##ROUNDING_MODE.expected, \
> (ARRAY)[i].RM_##ROUNDING_MODE.exceptions); \
> ROUND_RESTORE_ ## ROUNDING_MODE
> -#define RUN_TEST_LOOP_f_i_tg_u(FUNC_NAME, ARRAY, ROUNDING_MODE) \
> +#define RUN_TEST_LOOP_j_i_tg_u(FUNC_NAME, ARRAY, ROUNDING_MODE) \
> IF_ROUND_INIT_ ## ROUNDING_MODE \
> for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++) \
> - RUN_TEST_f_i_tg ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg.value, \
> + RUN_TEST_f_i_tg ((ARRAY)[i].arg_str, FUNC_NAME, \
> + (FLOAT)(ARRAY)[i].arg.value, \
> (ARRAY)[i].RM_##ROUNDING_MODE.expected, \
> (ARRAY)[i].RM_##ROUNDING_MODE.exceptions); \
> ROUND_RESTORE_ ## ROUNDING_MODE
> diff --git a/math/libm-test-fpclassify.inc b/math/libm-test-fpclassify.inc
> index c1c7e1ead1..2243146f40 100644
> --- a/math/libm-test-fpclassify.inc
> +++ b/math/libm-test-fpclassify.inc
> @@ -37,14 +37,14 @@ static const struct test_f_i_data fpclassify_test_data[] =
> TEST_f_i (fpclassify, -min_subnorm_value, FP_SUBNORMAL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> };
>
> -#if TEST_COND_intel96
> -static const struct test_f_i_data_u fpclassify_test_data_u[] =
> +#if TEST_COND_unnormal
> +static const struct test_j_i_data_u fpclassify_test_data_u[] =
> {
> - TEST_f_i (fpclassify, pseudo_zero, FP_NAN, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> - TEST_f_i (fpclassify, pseudo_inf, FP_NAN, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> - TEST_f_i (fpclassify, pseudo_qnan, FP_NAN, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> - TEST_f_i (fpclassify, pseudo_snan, FP_NAN, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> - TEST_f_i (fpclassify, pseudo_unnormal, FP_NAN, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> + TEST_j_i (fpclassify, pseudo_zero, FP_NAN, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> + TEST_j_i (fpclassify, pseudo_inf, FP_NAN, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> + TEST_j_i (fpclassify, pseudo_qnan, FP_NAN, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> + TEST_j_i (fpclassify, pseudo_snan, FP_NAN, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> + TEST_j_i (fpclassify, pseudo_unnormal, FP_NAN, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> };
> #endif
>
> @@ -52,8 +52,8 @@ static void
> fpclassify_test (void)
> {
> ALL_RM_TEST (fpclassify, 1, fpclassify_test_data, RUN_TEST_LOOP_f_i_tg, END);
> -#if TEST_COND_intel96
> - ALL_RM_TEST (fpclassify, 1, fpclassify_test_data_u, RUN_TEST_LOOP_f_i_tg_u, END);
> +#if TEST_COND_unnormal
> + ALL_RM_TEST (fpclassify, 1, fpclassify_test_data_u, RUN_TEST_LOOP_j_i_tg_u, END);
> #endif
> }
>
> diff --git a/math/libm-test-isinf.inc b/math/libm-test-isinf.inc
> index 7d4b27a45c..23b536ff17 100644
> --- a/math/libm-test-isinf.inc
> +++ b/math/libm-test-isinf.inc
> @@ -37,14 +37,14 @@ static const struct test_f_i_data isinf_test_data[] =
> TEST_f_b (isinf, -snan_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> };
>
> -#if TEST_COND_intel96
> -static const struct test_f_i_data_u isinf_test_data_u[] =
> +#if TEST_COND_unnormal
> +static const struct test_j_i_data_u isinf_test_data_u[] =
> {
> - TEST_f_b (isinf, pseudo_zero, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> - TEST_f_b (isinf, pseudo_inf, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> - TEST_f_b (isinf, pseudo_qnan, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> - TEST_f_b (isinf, pseudo_snan, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> - TEST_f_b (isinf, pseudo_unnormal, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> + TEST_j_b (isinf, pseudo_zero, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> + TEST_j_b (isinf, pseudo_inf, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> + TEST_j_b (isinf, pseudo_qnan, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> + TEST_j_b (isinf, pseudo_snan, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> + TEST_j_b (isinf, pseudo_unnormal, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> };
> #endif
>
> @@ -52,8 +52,8 @@ static void
> isinf_test (void)
> {
> ALL_RM_TEST (isinf, 1, isinf_test_data, RUN_TEST_LOOP_f_b_tg, END);
> -#if TEST_COND_intel96
> - ALL_RM_TEST (isinf, 1, isinf_test_data_u, RUN_TEST_LOOP_f_b_tg_u, END);
> +#if TEST_COND_unnormal
> + ALL_RM_TEST (isinf, 1, isinf_test_data_u, RUN_TEST_LOOP_j_b_tg_u, END);
> #endif
> }
>
> diff --git a/math/libm-test-isnan.inc b/math/libm-test-isnan.inc
> index 501bb1856f..489b9c666e 100644
> --- a/math/libm-test-isnan.inc
> +++ b/math/libm-test-isnan.inc
> @@ -37,14 +37,14 @@ static const struct test_f_i_data isnan_test_data[] =
> TEST_f_b (isnan, -snan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> };
>
> -#if TEST_COND_intel96
> -static const struct test_f_i_data_u isnan_test_data_u[] =
> +#if TEST_COND_unnormal
> +static const struct test_j_i_data_u isnan_test_data_u[] =
> {
> - TEST_f_b (isnan, pseudo_zero, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> - TEST_f_b (isnan, pseudo_inf, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> - TEST_f_b (isnan, pseudo_qnan, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> - TEST_f_b (isnan, pseudo_snan, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> - TEST_f_b (isnan, pseudo_unnormal, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> + TEST_j_b (isnan, pseudo_zero, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> + TEST_j_b (isnan, pseudo_inf, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> + TEST_j_b (isnan, pseudo_qnan, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> + TEST_j_b (isnan, pseudo_snan, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> + TEST_j_b (isnan, pseudo_unnormal, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> };
> #endif
>
> @@ -52,8 +52,8 @@ static void
> isnan_test (void)
> {
> ALL_RM_TEST (isnan, 1, isnan_test_data, RUN_TEST_LOOP_f_b_tg, END);
> -#if TEST_COND_intel96
> - ALL_RM_TEST (isnan, 1, isnan_test_data_u, RUN_TEST_LOOP_f_b_tg_u, END);
> +#if TEST_COND_unnormal
> + ALL_RM_TEST (isnan, 1, isnan_test_data_u, RUN_TEST_LOOP_j_b_tg_u, END);
> #endif
> }
>
> diff --git a/math/libm-test-issignaling.inc b/math/libm-test-issignaling.inc
> index bea61a3664..31012f08e6 100644
> --- a/math/libm-test-issignaling.inc
> +++ b/math/libm-test-issignaling.inc
> @@ -39,14 +39,14 @@ static const struct test_f_i_data issignaling_test_data[] =
> TEST_f_b (issignaling, -snan_value_MACRO, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> };
>
> -#if TEST_COND_intel96
> -static const struct test_f_i_data_u issignaling_test_data_u[] =
> +#if TEST_COND_unnormal
> +static const struct test_j_i_data_u issignaling_test_data_u[] =
> {
> - TEST_f_b (issignaling, pseudo_zero, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> - TEST_f_b (issignaling, pseudo_inf, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> - TEST_f_b (issignaling, pseudo_qnan, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> - TEST_f_b (issignaling, pseudo_snan, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> - TEST_f_b (issignaling, pseudo_unnormal, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> + TEST_j_b (issignaling, pseudo_zero, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> + TEST_j_b (issignaling, pseudo_inf, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> + TEST_j_b (issignaling, pseudo_qnan, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> + TEST_j_b (issignaling, pseudo_snan, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> + TEST_j_b (issignaling, pseudo_unnormal, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> };
> #endif
>
> @@ -54,8 +54,8 @@ static void
> issignaling_test (void)
> {
> ALL_RM_TEST (issignaling, 1, issignaling_test_data, RUN_TEST_LOOP_f_b_tg, END);
> -#if TEST_COND_intel96
> - ALL_RM_TEST (issignaling, 1, issignaling_test_data_u, RUN_TEST_LOOP_f_b_tg_u, END);
> +#if TEST_COND_unnormal
> + ALL_RM_TEST (issignaling, 1, issignaling_test_data_u, RUN_TEST_LOOP_j_b_tg_u, END);
> #endif
> }
>
> diff --git a/math/libm-test-support.h b/math/libm-test-support.h
> index ba67001454..c218e2611a 100644
> --- a/math/libm-test-support.h
> +++ b/math/libm-test-support.h
> @@ -168,6 +168,8 @@ extern const char doc[];
> #define TEST_COND_before_rounding (!TININESS_AFTER_ROUNDING)
> #define TEST_COND_after_rounding TININESS_AFTER_ROUNDING
>
> +#define TEST_COND_unnormal (TEST_COND_intel96 && defined TEST_UNNORMAL)
> +
> int enable_test (int);
> void init_max_error (const char *, int, int);
> void print_max_error (const char *);
> diff --git a/math/test-float64x.h b/math/test-float64x.h
> index 578323b809..59bda920ac 100644
> --- a/math/test-float64x.h
> +++ b/math/test-float64x.h
> @@ -40,3 +40,4 @@
> #define FTOSTR strfromf64x
> #define snan_value_MACRO SNANF64X
> #define FUNC_NARROW_PREFIX f64x
> +#define TEST_UNNORMAL 1
> diff --git a/math/test-ldouble.h b/math/test-ldouble.h
> index 6037782292..e0b7c94ca6 100644
> --- a/math/test-ldouble.h
> +++ b/math/test-ldouble.h
> @@ -41,3 +41,4 @@
> #define FTOSTR strfroml
> #define snan_value_MACRO SNANL
> #define TEST_FLOATN 0
> +#define TEST_UNNORMAL 1
>
More information about the Libc-alpha
mailing list