]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
fold-const.c (negate_expr_p): Correct/refine condition for transformations.
authorRoger Sayle <roger@eyesopen.com>
Mon, 13 Nov 2006 02:55:22 +0000 (02:55 +0000)
committerRoger Sayle <sayle@gcc.gnu.org>
Mon, 13 Nov 2006 02:55:22 +0000 (02:55 +0000)
* fold-const.c (negate_expr_p) <PLUS_EXPR, MINUS_EXPR>: Correct/refine
condition for transformations.  Use !HONOR_SIGN_DEPENDENT_ROUNDING
&& !HONOR_SIGNED_ZEROS instead of flag_unsafe_math_optimizations.
(fold_negate_expr) <PLUS_EXPR, MINUS_EXPR>: Likewise.

From-SVN: r118744

gcc/ChangeLog
gcc/fold-const.c

index ce01cd2c684f1f4471216f0100373204d5b6d661..2704ad3afc19b946ab6d200e738527e01aa8f628 100644 (file)
@@ -1,3 +1,10 @@
+2006-11-12  Roger Sayle  <roger@eyesopen.com>
+
+       * fold-const.c (negate_expr_p) <PLUS_EXPR, MINUS_EXPR>: Correct/refine
+       condition for transformations.  Use !HONOR_SIGN_DEPENDENT_ROUNDING
+       && !HONOR_SIGNED_ZEROS instead of flag_unsafe_math_optimizations.
+       (fold_negate_expr) <PLUS_EXPR, MINUS_EXPR>: Likewise.
+
 2006-11-12  Daniel Berlin  <dberlin@dberlin.org>
 
        Fix PR tree-optimization/29587
index eeec0c175bd44b182b2b0b583131cfa06fc92fde..c986503f10680dfd9c6720181496e41f5d2b661e 100644 (file)
@@ -981,7 +981,8 @@ negate_expr_p (tree t)
             && negate_expr_p (TREE_IMAGPART (t));
 
     case PLUS_EXPR:
-      if (FLOAT_TYPE_P (type) && !flag_unsafe_math_optimizations)
+      if (HONOR_SIGN_DEPENDENT_ROUNDING (TYPE_MODE (type))
+         || HONOR_SIGNED_ZEROS (TYPE_MODE (type)))
        return false;
       /* -(A + B) -> (-B) - A.  */
       if (negate_expr_p (TREE_OPERAND (t, 1))
@@ -993,7 +994,8 @@ negate_expr_p (tree t)
 
     case MINUS_EXPR:
       /* We can't turn -(A-B) into B-A when we honor signed zeros.  */
-      return (! FLOAT_TYPE_P (type) || flag_unsafe_math_optimizations)
+      return !HONOR_SIGN_DEPENDENT_ROUNDING (TYPE_MODE (type))
+            && !HONOR_SIGNED_ZEROS (TYPE_MODE (type))
             && reorder_operands_p (TREE_OPERAND (t, 0),
                                    TREE_OPERAND (t, 1));
 
@@ -1105,7 +1107,8 @@ fold_negate_expr (tree t)
       return TREE_OPERAND (t, 0);
 
     case PLUS_EXPR:
-      if (! FLOAT_TYPE_P (type) || flag_unsafe_math_optimizations)
+      if (!HONOR_SIGN_DEPENDENT_ROUNDING (TYPE_MODE (type))
+         && !HONOR_SIGNED_ZEROS (TYPE_MODE (type)))
        {
          /* -(A + B) -> (-B) - A.  */
          if (negate_expr_p (TREE_OPERAND (t, 1))
@@ -1129,7 +1132,8 @@ fold_negate_expr (tree t)
 
     case MINUS_EXPR:
       /* - (A - B) -> B - A  */
-      if ((! FLOAT_TYPE_P (type) || flag_unsafe_math_optimizations)
+      if (!HONOR_SIGN_DEPENDENT_ROUNDING (TYPE_MODE (type))
+         && !HONOR_SIGNED_ZEROS (TYPE_MODE (type))
          && reorder_operands_p (TREE_OPERAND (t, 0), TREE_OPERAND (t, 1)))
        return fold_build2 (MINUS_EXPR, type,
                            TREE_OPERAND (t, 1), TREE_OPERAND (t, 0));