From 762297d941e94600c6b81d5ccdd464872d9a9692 Mon Sep 17 00:00:00 2001 From: Roger Sayle Date: Thu, 3 Feb 2005 06:44:35 +0000 Subject: [PATCH] re PR middle-end/19405 (18_support/numeric_limits.cc fails on ppc-darwin (long doubles)) PR middle-end/19405 * real.h (REAL_MODE_FORMAT_COMPOSITE_P): New macro. * fold-const.c (const_binop): Avoid constant folding floating point operations in modes that use composite representations. * simplify-rtx.c (simplify_binary_operation): Likewise. From-SVN: r94653 --- gcc/ChangeLog | 8 ++++++++ gcc/fold-const.c | 7 +++++-- gcc/real.h | 6 ++++++ gcc/simplify-rtx.c | 8 ++++++-- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 70370e22055..b9a63952f47 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2005-02-02 Roger Sayle + + PR middle-end/19405 + * real.h (REAL_MODE_FORMAT_COMPOSITE_P): New macro. + * fold-const.c (const_binop): Avoid constant folding floating + point operations in modes that use composite representations. + * simplify-rtx.c (simplify_binary_operation): Likewise. + 2005-02-02 Geoffrey Keating * config/rs6000/altivec.md (altivec_dst): Make the first operand diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 22857428a5c..1d2efbd2c23 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -1517,9 +1517,12 @@ const_binop (enum tree_code code, tree arg1, tree arg2, int notrunc) /* Don't constant fold this floating point operation if the result may dependent upon the run-time rounding mode and - flag_rounding_math is set. */ + flag_rounding_math is set, or if GCC's software emulation + is unable to accurately represent the result. */ - if (flag_rounding_math + if ((flag_rounding_math + || (REAL_MODE_FORMAT_COMPOSITE_P (mode) + && !flag_unsafe_math_optimizations)) && (inexact || !real_identical (&result, &value))) return NULL_TREE; diff --git a/gcc/real.h b/gcc/real.h index 13f072e96a8..5c4e9c605d8 100644 --- a/gcc/real.h +++ b/gcc/real.h @@ -157,6 +157,12 @@ extern const struct real_format * #define REAL_MODE_FORMAT(MODE) (real_format_for_mode[(MODE) - MIN_MODE_FLOAT]) +/* The following macro determines whether the floating point format is + composite, i.e. may contain non-consecutive mantissa bits, in which + case compile-time FP overflow may not model run-time overflow. */ +#define REAL_MODE_FORMAT_COMPOSITE_P(MODE) \ + ((REAL_MODE_FORMAT(MODE))->pnan < (REAL_MODE_FORMAT (MODE))->p) + /* Declare functions in real.c. */ /* Binary or unary arithmetic on tree_code. */ diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 92567fe3c41..a1a774752cf 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -1346,8 +1346,12 @@ simplify_binary_operation (enum rtx_code code, enum machine_mode mode, /* Don't constant fold this floating point operation if the result may dependent upon the run-time rounding mode and - flag_rounding_math is set. */ - if (flag_rounding_math + flag_rounding_math is set, or if GCC's software emulation + is unable to accurately represent the result. */ + + if ((flag_rounding_math + || (REAL_MODE_FORMAT_COMPOSITE_P (mode) + && !flag_unsafe_math_optimizations)) && (inexact || !real_identical (&result, &value))) return NULL_RTX; -- 2.43.5