Commit e6f1c509 by Richard Biener Committed by Richard Biener

re PR tree-optimization/58459 (Loop invariant is not hoisted out of loop after r202525.)

2013-09-27  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/58459
	* tree-ssa-forwprop.c (forward_propagate_addr_expr): Remove
	restriction not propagating into loops.

	* gcc.dg/tree-ssa/ssa-pre-31.c: New testcase.

From-SVN: r202966
parent 6bda61a2
2013-09-27 Richard Biener <rguenther@suse.de>
PR tree-optimization/58459
* tree-ssa-forwprop.c (forward_propagate_addr_expr): Remove
restriction not propagating into loops.
2013-09-26 Florian Weimer <fw@deneb.enyo.de> 2013-09-26 Florian Weimer <fw@deneb.enyo.de>
* tree-ssa.h (walk_use_def_chains_fn, walk_use_def_chains): Delete. * tree-ssa.h (walk_use_def_chains_fn, walk_use_def_chains): Delete.
......
2013-09-27 Richard Biener <rguenther@suse.de>
PR tree-optimization/58459
* gcc.dg/tree-ssa/ssa-pre-31.c: New testcase.
2013-09-26 Bernd Edlinger <bernd.edlinger@hotmail.de> 2013-09-26 Bernd Edlinger <bernd.edlinger@hotmail.de>
PR fortran/58113 PR fortran/58113
......
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-pre" } */
typedef struct {
unsigned int key;
} S;
typedef struct s1 {
unsigned int key;
unsigned int bits;
struct s1 *left, *right;
}S1;
extern S a[1024];
static inline int bar( S* p, S1* n )
{
S1 *curr;
S1 *next;
if ( n->left == n )
return (int)(p->key == n->key);
curr = n;
next = n->left;
while (curr->bits > next->bits ) {
curr = next;
if (p->key & (1 << curr->bits))
next = curr->right;
else
next = curr->left;
}
return (int)(p->key == next->key);
}
int foo (S1 *root, int N)
{
volatile int r;
int i,j;
for (i=0; i<N; i++)
for (j=0;j<1024; j++)
r = bar(&a[j], root);
return 0;
}
/* { dg-final { scan-tree-dump-times "key" 4 "pre" } } */
/* { dg-final { cleanup-tree-dump "pre" } } */
...@@ -1001,7 +1001,6 @@ forward_propagate_addr_expr_1 (tree name, tree def_rhs, ...@@ -1001,7 +1001,6 @@ forward_propagate_addr_expr_1 (tree name, tree def_rhs,
static bool static bool
forward_propagate_addr_expr (tree name, tree rhs) forward_propagate_addr_expr (tree name, tree rhs)
{ {
int stmt_loop_depth = bb_loop_depth (gimple_bb (SSA_NAME_DEF_STMT (name)));
imm_use_iterator iter; imm_use_iterator iter;
gimple use_stmt; gimple use_stmt;
bool all = true; bool all = true;
...@@ -1014,37 +1013,24 @@ forward_propagate_addr_expr (tree name, tree rhs) ...@@ -1014,37 +1013,24 @@ forward_propagate_addr_expr (tree name, tree rhs)
/* If the use is not in a simple assignment statement, then /* If the use is not in a simple assignment statement, then
there is nothing we can do. */ there is nothing we can do. */
if (gimple_code (use_stmt) != GIMPLE_ASSIGN) if (!is_gimple_assign (use_stmt))
{ {
if (!is_gimple_debug (use_stmt)) if (!is_gimple_debug (use_stmt))
all = false; all = false;
continue; continue;
} }
/* If the use is in a deeper loop nest, then we do not want gimple_stmt_iterator gsi = gsi_for_stmt (use_stmt);
to propagate non-invariant ADDR_EXPRs into the loop as that result = forward_propagate_addr_expr_1 (name, rhs, &gsi,
is likely adding expression evaluations into the loop. */ single_use_p);
if (bb_loop_depth (gimple_bb (use_stmt)) > stmt_loop_depth /* If the use has moved to a different statement adjust
&& !is_gimple_min_invariant (rhs)) the update machinery for the old statement too. */
if (use_stmt != gsi_stmt (gsi))
{ {
all = false; update_stmt (use_stmt);
continue; use_stmt = gsi_stmt (gsi);
} }
update_stmt (use_stmt);
{
gimple_stmt_iterator gsi = gsi_for_stmt (use_stmt);
result = forward_propagate_addr_expr_1 (name, rhs, &gsi,
single_use_p);
/* If the use has moved to a different statement adjust
the update machinery for the old statement too. */
if (use_stmt != gsi_stmt (gsi))
{
update_stmt (use_stmt);
use_stmt = gsi_stmt (gsi);
}
update_stmt (use_stmt);
}
all &= result; all &= result;
/* Remove intermediate now unused copy and conversion chains. */ /* Remove intermediate now unused copy and conversion chains. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment