OSDN Git Service

* tree-optimize.c (init_tree_optimization_passes): Move
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 23 Jun 2005 22:00:44 +0000 (22:00 +0000)
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 23 Jun 2005 22:00:44 +0000 (22:00 +0000)
        copy prop pass to run just before VRP.
        * tree-vrp.c (remove_range_assertions): Remove copies created
        by ASSERT_EXPR removal.

        * gcc.dg/tree-ssa/vrp16.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@101277 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/vrp16.c [new file with mode: 0644]
gcc/tree-optimize.c
gcc/tree-vrp.c

index cbf721b..c34a161 100644 (file)
@@ -1,3 +1,10 @@
+2005-06-23  Jeff Law  <law@redhat.com>
+
+       * tree-optimize.c (init_tree_optimization_passes): Move
+       copy prop pass to run just before VRP.
+       * tree-vrp.c (remove_range_assertions): Remove copies created
+       by ASSERT_EXPR removal.
+
 2005-06-23  Kazu Hirata  <kazu@codesourcery.com>
 
        PR tree-optimization/22117
index 135b528..bece831 100644 (file)
@@ -1,3 +1,7 @@
+2005-06-23  Jeff Law  <law@redhat.com>
+
+       * gcc.dg/tree-ssa/vrp16.c: New test.
+
 2005-06-23  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
 
        * lib/target-supports.exp: Add
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp16.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp16.c
new file mode 100644 (file)
index 0000000..e8fd4bd
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-vrp-details" } */
+
+
+extern void abort (void) __attribute__ ((__noreturn__));
+struct rtx_def;
+typedef struct rtx_def *rtx;
+struct rtx_def
+{
+  int code;
+};
+int
+nonlocal_mentioned_p (rtx x)
+{
+  if (x->code == 6 || x->code == 7)
+    if (x->code == 7)
+      if (x->code != 7)
+       abort ();
+}
+
+/* { dg-final { scan-tree-dump-times "Folding predicate .*to 0" 1 "vrp" } } */
+/* { dg-final { cleanup-tree-dump "vrp" } } */
+
index c2f4fc9..adeee3c 100644 (file)
@@ -407,8 +407,8 @@ init_tree_optimization_passes (void)
   NEXT_PASS (pass_fre);
   NEXT_PASS (pass_dce);
   NEXT_PASS (pass_forwprop);
-  NEXT_PASS (pass_vrp);
   NEXT_PASS (pass_copy_prop);
+  NEXT_PASS (pass_vrp);
   NEXT_PASS (pass_dce);
   NEXT_PASS (pass_merge_phi);
   NEXT_PASS (pass_dominator);
index 284208b..5ad94b2 100644 (file)
@@ -2641,7 +2641,10 @@ insert_range_assertions (void)
 }
 
 
-/* Convert range assertion expressions into the implied copies.
+/* Convert range assertion expressions into the implied copies and
+   copy propagate away the copies.  Doing the trivial copy propagation
+   here avoids the need to run the full copy propagation pass after
+   VRP. 
    
    FIXME, this will eventually lead to copy propagation removing the
    names that had useful range information attached to them.  For
@@ -2655,7 +2658,12 @@ insert_range_assertions (void)
    things like jump threading.
    
    The problem with keeping ASSERT_EXPRs around is that passes after
-   VRP need to handle them appropriately.  */
+   VRP need to handle them appropriately. 
+
+   Another approach would be to make the range information a first
+   class property of the SSA_NAME so that it can be queried from
+   any pass.  This is made somewhat more complex by the need for
+   multiple ranges to be associated with one SSA_NAME.  */
 
 static void
 remove_range_assertions (void)
@@ -2663,8 +2671,11 @@ remove_range_assertions (void)
   basic_block bb;
   block_stmt_iterator si;
 
+  /* Note that the BSI iterator bump happens at the bottom of the
+     loop and no bump is necessary if we're removing the statement
+     referenced by the current BSI.  */
   FOR_EACH_BB (bb)
-    for (si = bsi_start (bb); !bsi_end_p (si); bsi_next (&si))
+    for (si = bsi_start (bb); !bsi_end_p (si);)
       {
        tree stmt = bsi_stmt (si);
 
@@ -2673,10 +2684,26 @@ remove_range_assertions (void)
          {
            tree rhs = TREE_OPERAND (stmt, 1);
            tree cond = fold (ASSERT_EXPR_COND (rhs));
+           use_operand_p use_p;
+           imm_use_iterator iter;
+
            gcc_assert (cond != boolean_false_node);
            TREE_OPERAND (stmt, 1) = ASSERT_EXPR_VAR (rhs);
            update_stmt (stmt);
+
+           /* The statement is now a copy.  Propagate the RHS into
+              every use of the LHS.  */
+           FOR_EACH_IMM_USE_SAFE (use_p, iter, TREE_OPERAND (stmt, 0))
+             {
+               SET_USE (use_p, ASSERT_EXPR_VAR (rhs));
+               update_stmt (USE_STMT (use_p));
+             }
+
+           /* And finally, remove the copy, it is not needed.  */
+           bsi_remove (&si);
          }
+       else
+         bsi_next (&si);
       }
 }