diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2007-05-07 11:42:21 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2007-05-07 11:42:21 +0000 |
commit | 8d9d65619c4ed9bad4171a6cbc6919e074825760 (patch) | |
tree | 6875876f67a8868c139f99ccb0d56a375a8baec6 /gcc | |
parent | 2cb7995f0758c4863805c4f8320d918373ef0bb8 (diff) | |
download | gcc-8d9d65619c4ed9bad4171a6cbc6919e074825760.zip gcc-8d9d65619c4ed9bad4171a6cbc6919e074825760.tar.gz gcc-8d9d65619c4ed9bad4171a6cbc6919e074825760.tar.bz2 |
tree-ssa-dom.c (tree_ssa_dominator_optimize): Reset cfg_altered.
* tree-ssa-dom.c (tree_ssa_dominator_optimize): Reset cfg_altered.
Free dominance info before purging EH edges as well as after.
(eliminate_degenerate_phis): Likewise.
(propagate_rhs_into_lhs): Set cfg_altered to true instead of 1.
From-SVN: r124498
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/opt1.adb | 29 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/opt1.ads | 13 | ||||
-rw-r--r-- | gcc/tree-ssa-dom.c | 24 |
5 files changed, 68 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index de5e550..b4284ad 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2007-05-07 Eric Botcazou <ebotcazou@adacore.com> + + * tree-ssa-dom.c (tree_ssa_dominator_optimize): Reset cfg_altered. + Free dominance info before purging EH edges as well as after. + (eliminate_degenerate_phis): Likewise. + (propagate_rhs_into_lhs): Set cfg_altered to true instead of 1. + 2007-05-07 Jan Hubicka <jh@suse.cz> * gimplify.c (gimplify_expr): Do not crash when folding diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 099cbe5..64e1273 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2007-05-07 Eric Botcazou <ebotcazou@adacore.com> + + * gnat.dg/opt1.ad[sb]: New testcase. + 2007-05-07 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> PR fortran/31399 diff --git a/gcc/testsuite/gnat.dg/opt1.adb b/gcc/testsuite/gnat.dg/opt1.adb new file mode 100644 index 0000000..69bb813 --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt1.adb @@ -0,0 +1,29 @@ +-- { dg-do compile } +-- { dg-options "-O -gnatws" } + +package body Opt1 is + + function De_Linear_Index + (Index : Natural; + D : Natural; + Ind_Lengths : Dimention_Length) + return Dimension_Indexes + is + Len : Natural := 1; + Tmp_Ind : Natural := Index; + Tmp_Res : Natural; + Result : Dimension_Indexes (1 .. D); + begin + for J in 1 .. D loop + Len := Len * Ind_Lengths (J); + end loop; + + for J in Result'Range loop + Result (J) := Tmp_Res; + Tmp_Ind := Tmp_Ind - Len * (Result (J) - 1); + end loop; + + return Result; + end; + +end Opt1; diff --git a/gcc/testsuite/gnat.dg/opt1.ads b/gcc/testsuite/gnat.dg/opt1.ads new file mode 100644 index 0000000..247e7dc --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt1.ads @@ -0,0 +1,13 @@ +package Opt1 is + + type Dimention_Length is array (1 .. 16) of Natural; + + type Dimension_Indexes is array (Positive range <>) of Positive; + + function De_Linear_Index + (Index : Natural; + D : Natural; + Ind_Lengths : Dimention_Length) + return Dimension_Indexes; + +end Opt1; diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c index 6e1387f..d76c2a34 100644 --- a/gcc/tree-ssa-dom.c +++ b/gcc/tree-ssa-dom.c @@ -275,6 +275,7 @@ tree_ssa_dominator_optimize (void) init_walk_dominator_tree (&walk_data); calculate_dominance_info (CDI_DOMINATORS); + cfg_altered = false; /* We need to know which edges exit loops so that we can aggressively thread through loop headers to an exit @@ -320,17 +321,18 @@ tree_ssa_dominator_optimize (void) /* Thread jumps, creating duplicate blocks as needed. */ cfg_altered |= thread_through_all_blocks (); + if (cfg_altered) + free_dominance_info (CDI_DOMINATORS); + /* Removal of statements may make some EH edges dead. Purge such edges from the CFG as needed. */ if (!bitmap_empty_p (need_eh_cleanup)) { - cfg_altered |= tree_purge_all_dead_eh_edges (need_eh_cleanup); + if (tree_purge_all_dead_eh_edges (need_eh_cleanup)) + free_dominance_info (CDI_DOMINATORS); bitmap_zero (need_eh_cleanup); } - if (cfg_altered) - free_dominance_info (CDI_DOMINATORS); - /* Finally, remove everything except invariants in SSA_NAME_VALUE. Long term we will be able to let everything in SSA_NAME_VALUE @@ -2336,7 +2338,7 @@ propagate_rhs_into_lhs (tree stmt, tree lhs, tree rhs, bitmap interesting_names) te->count += e->count; remove_edge (e); - cfg_altered = 1; + cfg_altered = true; } else ei_next (&ei); @@ -2485,6 +2487,9 @@ eliminate_degenerate_phis (void) interesting_names = BITMAP_ALLOC (NULL); interesting_names1 = BITMAP_ALLOC (NULL); + calculate_dominance_info (CDI_DOMINATORS); + cfg_altered = false; + /* First phase. Eliminate degenerate PHIs via a dominator walk of the CFG. @@ -2493,7 +2498,6 @@ eliminate_degenerate_phis (void) phase in dominator order. Presumably this is because walking in dominator order leaves fewer PHIs for later examination by the worklist phase. */ - calculate_dominance_info (CDI_DOMINATORS); eliminate_degenerate_phis_1 (ENTRY_BLOCK_PTR, interesting_names); /* Second phase. Eliminate second order degenerate PHIs as well @@ -2522,18 +2526,20 @@ eliminate_degenerate_phis (void) } } + if (cfg_altered) + free_dominance_info (CDI_DOMINATORS); + /* Propagation of const and copies may make some EH edges dead. Purge such edges from the CFG as needed. */ if (!bitmap_empty_p (need_eh_cleanup)) { - cfg_altered |= tree_purge_all_dead_eh_edges (need_eh_cleanup); + if (tree_purge_all_dead_eh_edges (need_eh_cleanup)) + free_dominance_info (CDI_DOMINATORS); BITMAP_FREE (need_eh_cleanup); } BITMAP_FREE (interesting_names); BITMAP_FREE (interesting_names1); - if (cfg_altered) - free_dominance_info (CDI_DOMINATORS); return 0; } |