OSDN Git Service

2005-08-01 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 1 Aug 2005 08:52:59 +0000 (08:52 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 1 Aug 2005 08:52:59 +0000 (08:52 +0000)
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

gcc/ChangeLog
gcc/tree-ssa-loop-im.c
gcc/tree-ssa-math-opts.c

index 1f090f4..07b3141 100644 (file)
@@ -1,3 +1,14 @@
+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.
+
 2005-08-01  Razya Ladelsky  <razya@il.ibm.com>
 
         * cgraph.h (update_call_expr, cgraph_copy_node_for_versioning,
index e3476c6..9281079 100644 (file)
@@ -610,6 +610,7 @@ determine_invariantness_stmt (struct dom_walk_data *dw_data ATTRIBUTE_UNUSED,
          && (rhs = TREE_OPERAND (stmt, 1)) != NULL
          && TREE_CODE (rhs) == RDIV_EXPR
          && flag_unsafe_math_optimizations
+         && !flag_trapping_math
          && outermost_invariant_loop_expr (TREE_OPERAND (rhs, 1),
                                            loop_containing_stmt (stmt)) != NULL
          && outermost_invariant_loop_expr (rhs,
index 9544a6c..bff3c1d 100644 (file)
@@ -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 =