diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1b1faaaaec5..091ceb80c1a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2005-10-11 Richard Henderson + + PR tree-opt/24300 + * Makefile.in (tree-ssa-dce.o): Depend on CFGLOOP_H. + * tree-ssa-dce.c: Include cfgloop.h. + (tree_ssa_dce_loop, pass_dce_loop): New. + * tree-pass.h (pass_dce_loop): Declare it. + * passes.c (init_optimization_passes): Use it. + 2005-10-11 Eric Botcazou PR middle-end/24263 diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 027fa043e11..e72eef9338a 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -2230,7 +2230,7 @@ mode-switching.o : mode-switching.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ tree-ssa-dce.o : tree-ssa-dce.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) \ $(RTL_H) $(TM_P_H) $(TREE_FLOW_H) $(DIAGNOSTIC_H) $(TIMEVAR_H) $(TM_H) \ coretypes.h $(TREE_DUMP_H) tree-pass.h $(FLAGS_H) $(BASIC_BLOCK_H) \ - $(GGC_H) hard-reg-set.h $(OBSTACK_H) $(TREE_GIMPLE_H) + $(GGC_H) hard-reg-set.h $(OBSTACK_H) $(TREE_GIMPLE_H) $(CFGLOOP_H) tree-ssa-ccp.o : tree-ssa-ccp.c $(TREE_FLOW_H) $(CONFIG_H) \ $(SYSTEM_H) $(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(GGC_H) output.h \ $(DIAGNOSTIC_H) function.h $(TIMEVAR_H) $(TM_H) coretypes.h \ diff --git a/gcc/passes.c b/gcc/passes.c index daa752e541d..0053f70dcce 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -595,12 +595,7 @@ init_optimization_passes (void) p = &pass_vectorize.sub; NEXT_PASS (pass_lower_vector_ssa); - /* ??? The loop optimizers are not GC safe. See PR 21805. - Turn off GC while registering this pass. */ - pass_dce.todo_flags_finish &= ~TODO_ggc_collect; - NEXT_PASS (pass_dce); - pass_dce.todo_flags_finish |= TODO_ggc_collect; - gcc_assert (p != &pass_dce.next); + NEXT_PASS (pass_dce_loop); *p = NULL; p = &pass_loop2.sub; diff --git a/gcc/testsuite/gcc.dg/vect/pr24300.c b/gcc/testsuite/gcc.dg/vect/pr24300.c new file mode 100644 index 00000000000..26eae81af21 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr24300.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ + +static int *** foo (int); + +void +bar () +{ + int ***p = foo (2); +} + +extern int *nd; +extern int ***tc; +extern int *ap; +extern int *as; +extern float ss; + +static int *** +foo (int Fc) +{ + int i, j, s, p, n, t; + + n = 0; + for (s = 0; s < 4; s++) + n += nd[s]; + + for (i = 0; i < n; i++) + { + p = ap[i]; + s = as[i]; + for (j = 0; j < Fc; j++) + tc[p][s][j] = i * ss + j; + } + + return (tc); +} diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h index 6674884944a..1f45ffd5719 100644 --- a/gcc/tree-pass.h +++ b/gcc/tree-pass.h @@ -243,6 +243,7 @@ extern struct tree_opt_pass pass_build_ssa; extern struct tree_opt_pass pass_del_ssa; extern struct tree_opt_pass pass_dominator; extern struct tree_opt_pass pass_dce; +extern struct tree_opt_pass pass_dce_loop; extern struct tree_opt_pass pass_cd_dce; extern struct tree_opt_pass pass_merge_phi; extern struct tree_opt_pass pass_may_alias; diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c index 8902d2a2e0a..6ad8cf26e5a 100644 --- a/gcc/tree-ssa-dce.c +++ b/gcc/tree-ssa-dce.c @@ -64,6 +64,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA #include "tree-pass.h" #include "timevar.h" #include "flags.h" +#include "cfgloop.h" static struct stmt_stats { @@ -941,6 +942,13 @@ tree_ssa_dce (void) perform_tree_ssa_dce (/*aggressive=*/false); } +static void +tree_ssa_dce_loop (void) +{ + perform_tree_ssa_dce (/*aggressive=*/false); + free_numbers_of_iterations_estimates (current_loops); +} + static void tree_ssa_cd_dce (void) { @@ -974,6 +982,26 @@ struct tree_opt_pass pass_dce = 0 /* letter */ }; +struct tree_opt_pass pass_dce_loop = +{ + "dceloop", /* name */ + gate_dce, /* gate */ + tree_ssa_dce_loop, /* execute */ + NULL, /* sub */ + NULL, /* next */ + 0, /* static_pass_number */ + TV_TREE_DCE, /* tv_id */ + PROP_cfg | PROP_ssa | PROP_alias, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + TODO_dump_func + | TODO_update_ssa_no_phi + | TODO_cleanup_cfg + | TODO_verify_ssa, /* todo_flags_finish */ + 0 /* letter */ +}; + struct tree_opt_pass pass_cd_dce = { "cddce", /* name */