summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-math-opts.c
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2005-08-01 08:52:59 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2005-08-01 08:52:59 +0000
commit685b24f5babbfea0e9374a5fd393cf9e1c7bcd0d (patch)
tree6c454da7c03895efb5f70d5099fddba16413ef4a /gcc/tree-ssa-math-opts.c
parentc5235c0b315ea8765f6b018a98fee695d60d9469 (diff)
downloadgcc-685b24f5babbfea0e9374a5fd393cf9e1c7bcd0d.tar.gz
2005-08-01 Richard Guenther <rguenther@suse.de>
PR tree-optimization/23109 * tree-ssa-math-opts.c (execute_cse_reciprocals_1): If trapping math is in effect, use post-dominator information to check if we'd in any case reach a trapping point before doing the reciprocal insertion. (execute_cse_reciprocals): Compute post-dominators, if necessary. * tree-ssa-loop-im.c (determine_invariantness_stmt): RDIV expressions are invariant only if trapping math is not in effect. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@102627 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-math-opts.c')
-rw-r--r--gcc/tree-ssa-math-opts.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c
index 9544a6c256c..bff3c1db21a 100644
--- a/gcc/tree-ssa-math-opts.c
+++ b/gcc/tree-ssa-math-opts.c
@@ -69,6 +69,7 @@ execute_cse_reciprocals_1 (block_stmt_iterator *bsi, tree def, bool phi)
imm_use_iterator use_iter;
tree t, new_stmt, type;
int count = 0;
+ bool ok = !flag_trapping_math;
/* Find uses. */
FOR_EACH_IMM_USE_FAST (use_p, use_iter, def)
@@ -77,13 +78,18 @@ execute_cse_reciprocals_1 (block_stmt_iterator *bsi, tree def, bool phi)
if (TREE_CODE (use_stmt) == MODIFY_EXPR
&& TREE_CODE (TREE_OPERAND (use_stmt, 1)) == RDIV_EXPR
&& TREE_OPERAND (TREE_OPERAND (use_stmt, 1), 1) == def)
- {
- if (++count == 2)
- break;
- }
+ {
+ ++count;
+ /* Check if this use post-dominates the insertion point. */
+ if (ok || dominated_by_p (CDI_POST_DOMINATORS, bsi->bb,
+ bb_for_stmt (use_stmt)))
+ ok = true;
+ }
+ if (count >= 2 && ok)
+ break;
}
- if (count < 2)
+ if (count < 2 || !ok)
return;
/* Make a variable with the replacement and substitute it. */
@@ -116,6 +122,10 @@ static void
execute_cse_reciprocals (void)
{
basic_block bb;
+
+ if (flag_trapping_math)
+ calculate_dominance_info (CDI_POST_DOMINATORS);
+
FOR_EACH_BB (bb)
{
block_stmt_iterator bsi;
@@ -143,6 +153,9 @@ execute_cse_reciprocals (void)
execute_cse_reciprocals_1 (&bsi, def, false);
}
}
+
+ if (flag_trapping_math)
+ free_dominance_info (CDI_POST_DOMINATORS);
}
struct tree_opt_pass pass_cse_reciprocals =