diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2004-10-12 20:50:08 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@gcc.gnu.org> | 2004-10-12 20:50:08 +0000 |
commit | 01d8c00bfc35c4abb8868f87a385639545b0e849 (patch) | |
tree | 307a8f37393b25c5868e66d16067530b6f501427 /gcc/tree-ssa-dom.c | |
parent | 967af719d20daa485fa058923111e3e418d17028 (diff) | |
download | gcc-01d8c00bfc35c4abb8868f87a385639545b0e849.zip gcc-01d8c00bfc35c4abb8868f87a385639545b0e849.tar.gz gcc-01d8c00bfc35c4abb8868f87a385639545b0e849.tar.bz2 |
re PR tree-optimization/17892 (gcc-4.0 should not reassociate floating point add or multiplication)
PR 17892.
OKed by Roger Sayle.
From-SVN: r88950
Diffstat (limited to 'gcc/tree-ssa-dom.c')
-rw-r--r-- | gcc/tree-ssa-dom.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c index 5d545bd..4ab3613 100644 --- a/gcc/tree-ssa-dom.c +++ b/gcc/tree-ssa-dom.c @@ -266,6 +266,7 @@ static void restore_currdefs_to_original_value (void); static void register_definitions_for_stmt (tree); static edge single_incoming_edge_ignoring_loop_edges (basic_block); static void restore_nonzero_vars_to_original_value (void); +static inline bool unsafe_associative_fp_binop (tree); /* Local version of fold that doesn't introduce cruft. */ @@ -1549,6 +1550,18 @@ record_equality (tree x, tree y) record_const_or_copy_1 (x, y, prev_x); } +/* Return true, if it is ok to do folding of an associative expression. + EXP is the tree for the associative expression. */ + +static inline bool +unsafe_associative_fp_binop (tree exp) +{ + enum tree_code code = TREE_CODE (exp); + return !(!flag_unsafe_math_optimizations + && (code == MULT_EXPR || code == PLUS_EXPR) + && FLOAT_TYPE_P (TREE_TYPE (exp))); +} + /* STMT is a MODIFY_EXPR for which we were unable to find RHS in the hash tables. Try to simplify the RHS using whatever equivalences we may have recorded. @@ -1608,7 +1621,7 @@ simplify_rhs_and_lookup_avail_expr (struct dom_walk_data *walk_data, tree rhs_def_rhs = TREE_OPERAND (rhs_def_stmt, 1); enum tree_code rhs_def_code = TREE_CODE (rhs_def_rhs); - if (rhs_code == rhs_def_code + if ((rhs_code == rhs_def_code && unsafe_associative_fp_binop (rhs)) || (rhs_code == PLUS_EXPR && rhs_def_code == MINUS_EXPR) || (rhs_code == MINUS_EXPR && rhs_def_code == PLUS_EXPR)) { |