From 179b5a554c64bbcd8cdbdd5acc9cda92bd5f9d84 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 11 Sep 2014 20:55:37 +0000 Subject: [PATCH] re PR target/58757 (Advertise the lack of denormal support on alpha without -mieee) 2014-09-11 Marc Glisse PR target/58757 gcc/c-family/ * c-cppbuiltin.c (builtin_define_float_constants): Correct __*_DENORM_MIN__ without denormals. gcc/ * ginclude/float.h (FLT_TRUE_MIN, DBL_TRUE_MIN, LDBL_TRUE_MIN): Directly forward to __*_DENORM_MIN__. gcc/testsuite/ * gcc.dg/c11-true_min-1.c: New testcase. From-SVN: r215191 --- gcc/ChangeLog | 6 ++++++ gcc/c-family/ChangeLog | 6 ++++++ gcc/c-family/c-cppbuiltin.c | 21 +++++++-------------- gcc/ginclude/float.h | 12 ------------ gcc/testsuite/ChangeLog | 21 +++++++++++++-------- gcc/testsuite/gcc.dg/c11-true_min-1.c | 17 +++++++++++++++++ 6 files changed, 49 insertions(+), 34 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/c11-true_min-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c0498fac287..117f7f3e378 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2014-09-11 Marc Glisse + + PR target/58757 + * ginclude/float.h (FLT_TRUE_MIN, DBL_TRUE_MIN, LDBL_TRUE_MIN): + Directly forward to __*_DENORM_MIN__. + 2014-09-11 David Malcolm * rtl.h (LABEL_REF_LABEL): New macro. diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index f24696db23b..ca22822649a 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2014-09-11 Marc Glisse + + PR target/58757 + * c-cppbuiltin.c (builtin_define_float_constants): Correct + __*_DENORM_MIN__ without denormals. + 2014-09-10 Jakub Jelinek * c-ubsan.c (ubsan_instrument_division, ubsan_instrument_shift, diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c index 411ca194ada..da206766560 100644 --- a/gcc/c-family/c-cppbuiltin.c +++ b/gcc/c-family/c-cppbuiltin.c @@ -270,21 +270,14 @@ builtin_define_float_constants (const char *name_prefix, sprintf (buf, "0x1p%d", 1 - fmt->p); builtin_define_with_hex_fp_value (name, type, decimal_dig, buf, fp_suffix, fp_cast); - /* For C++ std::numeric_limits::denorm_min. The minimum denormalized - positive floating-point number, b**(emin-p). Zero for formats that - don't support denormals. */ + /* For C++ std::numeric_limits::denorm_min and C11 *_TRUE_MIN. + The minimum denormalized positive floating-point number, b**(emin-p). + The minimum normalized positive floating-point number for formats + that don't support denormals. */ sprintf (name, "__%s_DENORM_MIN__", name_prefix); - if (fmt->has_denorm) - { - sprintf (buf, "0x1p%d", fmt->emin - fmt->p); - builtin_define_with_hex_fp_value (name, type, decimal_dig, - buf, fp_suffix, fp_cast); - } - else - { - sprintf (buf, "0.0%s", fp_suffix); - builtin_define_with_value (name, buf, 0); - } + sprintf (buf, "0x1p%d", fmt->emin - (fmt->has_denorm ? fmt->p : 1)); + builtin_define_with_hex_fp_value (name, type, decimal_dig, + buf, fp_suffix, fp_cast); sprintf (name, "__%s_HAS_DENORM__", name_prefix); builtin_define_with_value (name, fmt->has_denorm ? "1" : "0", 0); diff --git a/gcc/ginclude/float.h b/gcc/ginclude/float.h index a8e05bfcdf7..4927f3614ad 100644 --- a/gcc/ginclude/float.h +++ b/gcc/ginclude/float.h @@ -178,21 +178,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #undef FLT_TRUE_MIN #undef DBL_TRUE_MIN #undef LDBL_TRUE_MIN -#if __FLT_HAS_DENORM__ #define FLT_TRUE_MIN __FLT_DENORM_MIN__ -#else -#define FLT_TRUE_MIN __FLT_MIN__ -#endif -#if __DBL_HAS_DENORM__ #define DBL_TRUE_MIN __DBL_DENORM_MIN__ -#else -#define DBL_TRUE_MIN __DBL_MIN__ -#endif -#if __LDBL_HAS_DENORM__ #define LDBL_TRUE_MIN __LDBL_DENORM_MIN__ -#else -#define LDBL_TRUE_MIN __LDBL_MIN__ -#endif #endif /* C11 */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3f88bb66c7e..3aba1c7026a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-09-11 Marc Glisse + + PR target/58757 + * gcc.dg/c11-true_min-1.c: New testcase. + 2014-09-11 Paolo Carlini PR c++/61489 @@ -10,14 +15,14 @@ 2014-09-11 Bernd Schmidt - * gcc.dg/compat/struct-by-value-13_main.c (struct_by_value_13_x): - Fix declaration. - * gcc.dg/compat/struct-by-value-16a_main.c (struct_by_value_16a_x): - Fix declaration. - * gcc.dg/compat/struct-by-value-17a_main.c (struct_by_value_17a_x): - Fix declaration. - * gcc.dg/compat/struct-by-value-18a_main.c (struct_by_value_18a_x): - Fix declaration. + * gcc.dg/compat/struct-by-value-13_main.c (struct_by_value_13_x): + Fix declaration. + * gcc.dg/compat/struct-by-value-16a_main.c (struct_by_value_16a_x): + Fix declaration. + * gcc.dg/compat/struct-by-value-17a_main.c (struct_by_value_17a_x): + Fix declaration. + * gcc.dg/compat/struct-by-value-18a_main.c (struct_by_value_18a_x): + Fix declaration. 2014-09-10 Jan Hubicka diff --git a/gcc/testsuite/gcc.dg/c11-true_min-1.c b/gcc/testsuite/gcc.dg/c11-true_min-1.c new file mode 100644 index 00000000000..dcb761ccd53 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c11-true_min-1.c @@ -0,0 +1,17 @@ +/* { dg-do run } */ +/* { dg-options "-std=c11" } */ + +/* Test that the smallest positive value is not 0. This needs to be true + even when denormals are not supported, so we do not pass any flag + like -mieee. If it fails on alpha, see PR 58757. */ + +#include + +int main(){ + volatile float f = FLT_TRUE_MIN; + volatile double d = DBL_TRUE_MIN; + volatile long double l = LDBL_TRUE_MIN; + if (f == 0 || d == 0 || l == 0) + __builtin_abort (); + return 0; +} -- 2.30.2