tree-optimization/112767 - spurious diagnostic after sccp/loop-split swap
We are diagnosing an unreachable loop which we only manage to elide after the copyprop pass after sccp which leaves the code open for diagnosing by the intermittent ivcanon pass. The following makes sure to clean things up a bit earlier, propagating constant final values to uses immediately. PR tree-optimization/112767 * tree-scalar-evolution.cc (final_value_replacement_loop): Propagate constants to immediate uses immediately. * gcc.dg/tree-ssa/pr112767.c: New testcase. * gcc.dg/graphite/pr83255.c: Disable SCCP.
This commit is contained in:
parent
8a6062a47b
commit
2dde9f326d
3 changed files with 29 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
|||
/* { dg-do run } */
|
||||
/* { dg-options "-O -floop-nest-optimize -fdump-tree-graphite-details" } */
|
||||
/* { dg-options "-O -floop-nest-optimize -fno-tree-scev-cprop -fdump-tree-graphite-details" } */
|
||||
|
||||
int rx, in;
|
||||
|
||||
|
|
18
gcc/testsuite/gcc.dg/tree-ssa/pr112767.c
Normal file
18
gcc/testsuite/gcc.dg/tree-ssa/pr112767.c
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-O3" } */
|
||||
|
||||
double reg_dict[32];
|
||||
|
||||
void foo(int);
|
||||
|
||||
void initialize()
|
||||
{
|
||||
int i=8;
|
||||
for (int phi=0; phi<8; ++phi) {
|
||||
reg_dict[i]=0; /* { dg-bogus "undefined behavior" } */
|
||||
int sn = 0;
|
||||
if (i < 16) sn = 20;
|
||||
foo(sn);
|
||||
++i;
|
||||
}
|
||||
}
|
|
@ -3841,11 +3841,20 @@ final_value_replacement_loop (class loop *loop)
|
|||
print_gimple_stmt (dump_file, phi, 0);
|
||||
fprintf (dump_file, " with expr: ");
|
||||
print_generic_expr (dump_file, def);
|
||||
fprintf (dump_file, "\n");
|
||||
}
|
||||
any = true;
|
||||
def = unshare_expr (def);
|
||||
remove_phi_node (&psi, false);
|
||||
|
||||
/* Propagate constants immediately. */
|
||||
if (CONSTANT_CLASS_P (def))
|
||||
{
|
||||
replace_uses_by (rslt, def);
|
||||
release_ssa_name (rslt);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Create the replacement statements. */
|
||||
gimple_seq stmts;
|
||||
def = force_gimple_operand (def, &stmts, false, NULL_TREE);
|
||||
|
@ -3877,7 +3886,7 @@ final_value_replacement_loop (class loop *loop)
|
|||
gsi_insert_seq_before (&gsi, stmts, GSI_SAME_STMT);
|
||||
if (dump_file)
|
||||
{
|
||||
fprintf (dump_file, "\n final stmt:\n ");
|
||||
fprintf (dump_file, " final stmt:\n ");
|
||||
print_gimple_stmt (dump_file, SSA_NAME_DEF_STMT (rslt), 0);
|
||||
fprintf (dump_file, "\n");
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue