]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix some confusion with IEEE minus zero.
authorPaul Eggert <eggert@twinsun.com>
Fri, 14 Nov 1997 14:30:01 +0000 (14:30 +0000)
committerJeff Law <law@gcc.gnu.org>
Fri, 14 Nov 1997 14:30:01 +0000 (07:30 -0700)
        * real.h (REAL_VALUES_IDENTICAL): New macro.

        * expr.c (is_zeros_p): Don't consider -0.0 to be all zeros.
        * fold-const.c (operand_equal_p): Don't consider -0.0 to be
        identical to 0.0.
        * tree.c (simple_cst_equal): Don't consider -0.0 to have the
        same tree structure as 0.0.

        * varasm.c (immed_real_const_1): Use new REAL_VALUES_IDENTICAL
        macro instead of doing it by hand.

From-SVN: r16488

gcc/ChangeLog
gcc/expr.c
gcc/fold-const.c
gcc/real.h
gcc/tree.c
gcc/varasm.c

index 3dc32dd95184d70de1e73129d1ebcf3975254715..58efb4915a1ee17183a1bc3b6ee48f76e8e063ca 100644 (file)
@@ -1,3 +1,18 @@
+1997-11-14  Paul Eggert  <eggert@twinsun.com>
+
+        Fix some confusion with IEEE minus zero.
+
+        * real.h (REAL_VALUES_IDENTICAL): New macro.
+
+        * expr.c (is_zeros_p): Don't consider -0.0 to be all zeros.
+        * fold-const.c (operand_equal_p): Don't consider -0.0 to be
+        identical to 0.0.
+        * tree.c (simple_cst_equal): Don't consider -0.0 to have the
+        same tree structure as 0.0.
+
+        * varasm.c (immed_real_const_1): Use new REAL_VALUES_IDENTICAL
+        macro instead of doing it by hand.
+
 Fri Nov 14 07:24:20 1997  Richard Henderson  <rth@cygnus.com>
 
        * alpha.c (call_operand): Any reg is valid for WinNT.
index 1715578826bc9e2417264308080a610fa8a829d9..1097ac4f13c7803c465112d06f8de6420e6c8fbc 100644 (file)
@@ -3440,7 +3440,7 @@ is_zeros_p (exp)
        is_zeros_p (TREE_REALPART (exp)) && is_zeros_p (TREE_IMAGPART (exp));
 
     case REAL_CST:
-      return REAL_VALUES_EQUAL (TREE_REAL_CST (exp), dconst0);
+      return REAL_VALUES_IDENTICAL (TREE_REAL_CST (exp), dconst0);
 
     case CONSTRUCTOR:
       if (TREE_TYPE (exp) && TREE_CODE (TREE_TYPE (exp)) == SET_TYPE)
index da18997acc335751d216c4975a1ef3476a113852..fefd5e06a8d263d2ca2572fb8b64083dd0e84520 100644 (file)
@@ -1772,8 +1772,8 @@ operand_equal_p (arg0, arg1, only_const)
       case REAL_CST:
        return (! TREE_CONSTANT_OVERFLOW (arg0)
                && ! TREE_CONSTANT_OVERFLOW (arg1)
-               && REAL_VALUES_EQUAL (TREE_REAL_CST (arg0),
-                                     TREE_REAL_CST (arg1)));
+               && REAL_VALUES_IDENTICAL (TREE_REAL_CST (arg0),
+                                         TREE_REAL_CST (arg1)));
 
       case COMPLEX_CST:
        return (operand_equal_p (TREE_REALPART (arg0), TREE_REALPART (arg1),
index 835c702f7d313393ea2da37af61128db543a4fec..504a69a7c28575a54f8efc935563d2d8802e7aca 100644 (file)
@@ -294,6 +294,13 @@ do { REAL_VALUE_TYPE in = (IN);  /* Make sure it's not in a register.  */\
 #define REAL_VALUE_TO_TARGET_LONG_DOUBLE(a, b) REAL_VALUE_TO_TARGET_DOUBLE (a, b)
 #endif
 
+/* Compare two floating-point objects for bitwise identity.
+   This is not the same as comparing for equality on IEEE hosts:
+   -0.0 equals 0.0 but they are not identical, and conversely
+   two NaNs might be identical but they cannot be equal.  */
+#define REAL_VALUES_IDENTICAL(x, y) \
+  (!bcmp ((char *) &(x), (char *) &(y), sizeof (REAL_VALUE_TYPE)))
+
 /* Compare two floating-point values for equality.  */
 #ifndef REAL_VALUES_EQUAL
 #define REAL_VALUES_EQUAL(x, y) ((x) == (y))
index d5eabaea008a5c1bdc64cf8525dd89341936cc9a..ee2b96b25e25fe568917795bc9e3aebc410af202 100644 (file)
@@ -3778,7 +3778,7 @@ simple_cst_equal (t1, t2)
        && TREE_INT_CST_HIGH (t1) == TREE_INT_CST_HIGH (t2);
 
     case REAL_CST:
-      return REAL_VALUES_EQUAL (TREE_REAL_CST (t1), TREE_REAL_CST (t2));
+      return REAL_VALUES_IDENTICAL (TREE_REAL_CST (t1), TREE_REAL_CST (t2));
 
     case STRING_CST:
       return TREE_STRING_LENGTH (t1) == TREE_STRING_LENGTH (t2)
index 3210aa2e65c6502e59216289d3363bb5a02a5575..32419c66dda195e91c3c046e8e73b988ca23ce26 100644 (file)
@@ -2230,8 +2230,7 @@ immed_real_const_1 (d, mode)
 
   /* Detect special cases.  */
 
-  /* Avoid REAL_VALUES_EQUAL here in order to distinguish minus zero.  */
-  if (!bcmp ((char *) &dconst0, (char *) &d, sizeof d))
+  if (REAL_VALUES_IDENTICAL (dconst0, d))
     return CONST0_RTX (mode);
   /* Check for NaN first, because some ports (specifically the i386) do not
      emit correct ieee-fp code by default, and thus will generate a core