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
This commit is contained in:
Jeff Law 2005-06-23 16:00:44 -06:00 committed by Jeff Law
parent 32aa3bffc3
commit 9490876243
5 changed files with 65 additions and 4 deletions

View 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

View 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

View File

@ -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" } } */

View 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);

View 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);
}
}