aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJeff Law <law@redhat.com>2005-06-23 16:00:44 -0600
committerJeff Law <law@gcc.gnu.org>2005-06-23 16:00:44 -0600
commit949087624366a022cbe51f395eb41748cb0921fe (patch)
treee04fe30725945b297720279d7f55cee8f6677e1e /gcc
parent32aa3bffc3be895994b3fa8a35c4c7d66e5fc8c6 (diff)
downloadgcc-949087624366a022cbe51f395eb41748cb0921fe.zip
gcc-949087624366a022cbe51f395eb41748cb0921fe.tar.gz
gcc-949087624366a022cbe51f395eb41748cb0921fe.tar.bz2
tree-optimize.c (init_tree_optimization_passes): Move copy prop pass to run just before VRP.
* 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. * gcc.dg/tree-ssa/vrp16.c: New test. From-SVN: r101277
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/vrp16.c23
-rw-r--r--gcc/tree-optimize.c2
-rw-r--r--gcc/tree-vrp.c33
5 files changed, 65 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index cbf721b..c34a161 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 135b528..bece831 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..e8fd4bd
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp16.c
@@ -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" } } */
+
diff --git a/gcc/tree-optimize.c b/gcc/tree-optimize.c
index c2f4fc9..adeee3c 100644
--- a/gcc/tree-optimize.c
+++ b/gcc/tree-optimize.c
@@ -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);
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 284208b..5ad94b2 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -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);
}
}