]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/19405 (18_support/numeric_limits.cc fails on ppc-darwin (long doubles))
authorRoger Sayle <roger@eyesopen.com>
Thu, 3 Feb 2005 06:44:35 +0000 (06:44 +0000)
committerRoger Sayle <sayle@gcc.gnu.org>
Thu, 3 Feb 2005 06:44:35 +0000 (06:44 +0000)
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
gcc/fold-const.c
gcc/real.h
gcc/simplify-rtx.c

index 70370e2205508a5994a734daee88c09971df3171..b9a63952f471d3b883391e8e7b387e5101a12951 100644 (file)
@@ -1,3 +1,11 @@
+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
index 22857428a5c575c890ee705240db561a093d35eb..1d2efbd2c237a1cfcdc2d1b5b8f88bf38cf24ebe 100644 (file)
@@ -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;
 
index 13f072e96a88c62e13b2fbb198d02df033f27678..5c4e9c605d81eeb78576e2731171da1cfebe37d2 100644 (file)
@@ -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.  */
index 92567fe3c41b79d4bda8df41990916b5d746dc52..a1a774752cf38209f7d134171ff338dcd85d72dc 100644 (file)
@@ -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;