fold-const.c (fold <EQ_EXPR>): Don't fold x == x only if x is a floating point type...
authorRoger Sayle <roger@eyesopen.com>
Tue, 10 Jun 2003 13:00:17 +0000 (13:00 +0000)
committerRoger Sayle <sayle@gcc.gnu.org>
Tue, 10 Jun 2003 13:00:17 +0000 (13:00 +0000)
* fold-const.c (fold <EQ_EXPR>):  Don't fold x == x only if x
is a floating point type *and* we currently honor NaNs.
(fold <NE_EXPR>): Likewise.

From-SVN: r67700

gcc/ChangeLog
gcc/fold-const.c

index 3c34fe2c21fd2d95649329f8396e93b9291c5b9d..6ef9b93146028be549c6b88462ffa63ef012e20a 100644 (file)
@@ -1,3 +1,9 @@
+2003-06-10  Roger Sayle  <roger@eyesopen.com>
+
+       * fold-const.c (fold <EQ_EXPR>):  Don't fold x == x only if x
+       is a floating point type *and* we currently honor NaNs.
+       (fold <NE_EXPR>): Likewise.
+
 2003-06-10  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/11131
index 1f118e891eb6cf88a5c33ce28e398f5e0a38e824..7b0f2cc533e633eedf30a7e8a8db8af40a896ed7 100644 (file)
@@ -7046,15 +7046,18 @@ fold (expr)
            case EQ_EXPR:
            case GE_EXPR:
            case LE_EXPR:
-             if (! FLOAT_TYPE_P (TREE_TYPE (arg0)))
+             if (! FLOAT_TYPE_P (TREE_TYPE (arg0))
+                 || ! HONOR_NANS (TYPE_MODE (TREE_TYPE (arg0))))
                return constant_boolean_node (1, type);
              code = EQ_EXPR;
              TREE_SET_CODE (t, code);
              break;
 
            case NE_EXPR:
-             /* For NE, we can only do this simplification if integer.  */
-             if (FLOAT_TYPE_P (TREE_TYPE (arg0)))
+             /* For NE, we can only do this simplification if integer
+                or we don't honor IEEE floating point NaNs.  */
+             if (FLOAT_TYPE_P (TREE_TYPE (arg0))
+                 && HONOR_NANS (TYPE_MODE (TREE_TYPE (arg0))))
                break;
              /* ... fall through ...  */
            case GT_EXPR: