+2005-02-02 Roger Sayle <roger@eyesopen.com>
+
+ 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 <geoffk@apple.com>
* config/rs6000/altivec.md (altivec_dst): Make the first operand
/* 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;
#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. */
/* 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;