diff options
author | Sebastian Pop <sebastian.pop@amd.com> | 2010-01-10 21:46:42 +0000 |
---|---|---|
committer | Sebastian Pop <spop@gcc.gnu.org> | 2010-01-10 21:46:42 +0000 |
commit | e1496917f1a8651786675c13c702de19518cf8e4 (patch) | |
tree | 0e6f539a020e4f9c2e0602ac03b56ada5e952081 /gcc/sese.c | |
parent | dadcb84c8f3e312a42496ba959e9568673823b34 (diff) | |
download | gcc-e1496917f1a8651786675c13c702de19518cf8e4.zip gcc-e1496917f1a8651786675c13c702de19518cf8e4.tar.gz gcc-e1496917f1a8651786675c13c702de19518cf8e4.tar.bz2 |
re PR middle-end/42393 ([graphite] internal compiler error: in check_loop_closed_ssa_use)
Fix PR42393.
2010-01-08 Sebastian Pop <sebastian.pop@amd.com>
PR middle-end/42393
* graphite-clast-to-gimple.c: Fix formatting.
* sese.c (defined_in_loop_p): Renamed name_defined_in_loop_p.
(expr_defined_in_loop_p): New.
(add_loop_exit_phis): Also handle full expressions: remove from
the rename_map the expressions defined in the loop that we're closing.
* testsuite/gfortran.dg/graphite/pr42393-1.f90: New.
* testsuite/gfortran.dg/graphite/pr42393.f90: Add new flags
-fno-loop-block -fno-loop-interchange -fno-loop-strip-mine to also
make this testcase useful in the Graphite branch.
From-SVN: r155795
Diffstat (limited to 'gcc/sese.c')
-rw-r--r-- | gcc/sese.c | 59 |
1 files changed, 44 insertions, 15 deletions
@@ -1037,13 +1037,41 @@ get_false_edge_from_guard_bb (basic_block bb) /* Returns true when NAME is defined in LOOP. */ static bool -defined_in_loop_p (tree name, loop_p loop) +name_defined_in_loop_p (tree name, loop_p loop) { gimple stmt = SSA_NAME_DEF_STMT (name); return (gimple_bb (stmt)->loop_father == loop); } +/* Returns true when EXPR contains SSA_NAMEs defined in LOOP. */ + +static bool +expr_defined_in_loop_p (tree expr, loop_p loop) +{ + switch (TREE_CODE_LENGTH (TREE_CODE (expr))) + { + case 3: + return expr_defined_in_loop_p (TREE_OPERAND (expr, 0), loop) + || expr_defined_in_loop_p (TREE_OPERAND (expr, 1), loop) + || expr_defined_in_loop_p (TREE_OPERAND (expr, 2), loop); + + case 2: + return expr_defined_in_loop_p (TREE_OPERAND (expr, 0), loop) + || expr_defined_in_loop_p (TREE_OPERAND (expr, 1), loop); + + case 1: + return expr_defined_in_loop_p (TREE_OPERAND (expr, 0), loop); + + case 0: + return TREE_CODE (expr) == SSA_NAME + && name_defined_in_loop_p (expr, loop); + + default: + return false; + } +} + /* Returns the gimple statement that uses NAME outside the loop it is defined in, returns NULL if there is no such loop close phi node. An invariant of the loop closed SSA form is that the only use of a @@ -1100,26 +1128,34 @@ add_loop_exit_phis (void **slot, void *data) struct rename_map_elt_s *entry; alep_p a; loop_p loop; - tree expr, new_name; + tree expr, new_name, old_name; bool def_in_loop_p, used_outside_p, need_close_phi_p; gimple old_close_phi; - if (!slot || !data) + if (!slot || !*slot || !data) return 1; entry = (struct rename_map_elt_s *) *slot; a = (alep_p) data; loop = a->loop; - expr = entry->expr; + new_name = expr = entry->expr; + old_name = entry->old_name; + + def_in_loop_p = expr_defined_in_loop_p (expr, loop); + if (!def_in_loop_p) + return 1; + + /* Remove the old rename from the map when the expression is defined + in the loop that we're closing. */ + free (*slot); + *slot = NULL; if (TREE_CODE (expr) != SSA_NAME) return 1; - new_name = expr; - def_in_loop_p = defined_in_loop_p (new_name, loop); - old_close_phi = alive_after_loop (entry->old_name); + old_close_phi = alive_after_loop (old_name); used_outside_p = (old_close_phi != NULL); - need_close_phi_p = (def_in_loop_p && used_outside_p + need_close_phi_p = (used_outside_p && close_phi_not_yet_inserted_p (loop, new_name)); /* Insert a loop close phi node. */ @@ -1136,13 +1172,6 @@ add_loop_exit_phis (void **slot, void *data) new_res)); } - /* Remove the old rename from the map. */ - if (def_in_loop_p && *slot) - { - free (*slot); - *slot = NULL; - } - return 1; } |