+2005-11-16 Eric Botcazou <ebotcazou@adacore.com>
+
+ * fold-const.c (const_binop): Don't constant fold the operation
+ if the result has overflowed and flag_trapping_math.
+ * simplify-rtx.c (simplify_const_binary_operation): Likewise.
+
2005-11-16 Daniel Jacobowitz <dan@codesourcery.com>
* config/arm/unwind-arm.c (abort): Add prototype here.
inexact = real_arithmetic (&value, code, &d1, &d2);
real_convert (&result, mode, &value);
+ /* Don't constant fold this floating point operation if
+ the result has overflowed and flag_trapping_math. */
+
+ if (flag_trapping_math
+ && MODE_HAS_INFINITIES (mode)
+ && REAL_VALUE_ISINF (result)
+ && !REAL_VALUE_ISINF (d1)
+ && !REAL_VALUE_ISINF (d2))
+ return NULL_TREE;
+
/* 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, or if GCC's software emulation
&f0, &f1);
real_convert (&result, mode, &value);
+ /* Don't constant fold this floating point operation if
+ the result has overflowed and flag_trapping_math. */
+
+ if (flag_trapping_math
+ && MODE_HAS_INFINITIES (mode)
+ && REAL_VALUE_ISINF (result)
+ && !REAL_VALUE_ISINF (f0)
+ && !REAL_VALUE_ISINF (f1))
+ /* Overflow plus exception. */
+ return 0;
+
/* 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, or if GCC's software emulation
+2005-11-16 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gcc.dg/fold-overflow-1.c: New test.
+
2005-11-16 Daniel Jacobowitz <dan@codesourcery.com>
* gcc.dg/cleanup-5.c, gcc.dg/cleanup-8.c, gcc.dg/cleanup-9.c,
--- /dev/null
+/* { dg-compile } */
+/* { dg-options "-O -ftrapping-math" } */
+
+float f1 = __FLT_MAX__ + __FLT_MAX__;
+
+float foo1(void)
+{
+ return __FLT_MAX__ + __FLT_MAX__;
+}
+
+float f2 = 1.0f/0.0f;
+
+float foo2(void)
+{
+ return 1.0f/0.0f;
+}
+
+/* { dg-final { scan-assembler-times "2139095040" 2 } } */