+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
--- /dev/null
+/* { 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" } } */
+
}
-/* 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
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)
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);
{
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);
}
}