diff options
author | Roger Sayle <roger@eyesopen.com> | 2006-11-13 02:55:22 +0000 |
---|---|---|
committer | Roger Sayle <sayle@gcc.gnu.org> | 2006-11-13 02:55:22 +0000 |
commit | 1b43b96773b82117e3a194647a9e2cc3d8a3a6e0 (patch) | |
tree | 80381e45a819a560f58f1e183ef834d27176ae95 /gcc/fold-const.c | |
parent | 163b8581869310a93a40d44711095674ba76ca77 (diff) | |
download | gcc-1b43b96773b82117e3a194647a9e2cc3d8a3a6e0.zip gcc-1b43b96773b82117e3a194647a9e2cc3d8a3a6e0.tar.gz gcc-1b43b96773b82117e3a194647a9e2cc3d8a3a6e0.tar.bz2 |
fold-const.c (negate_expr_p): Correct/refine condition for transformations.
* 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
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index eeec0c1..c986503 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -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)); |