Commit e1496917 by Sebastian Pop Committed by Sebastian Pop

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
parent dadcb84c
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.
2010-01-08 Sebastian Pop <sebastian.pop@amd.com>
* graphite-scop-detection.c (exclude_component_ref): Removed.
(is_simple_operand): Removed.
(stmt_simple_for_scop_p): Remove use of is_simple_operand.
......
......@@ -812,10 +812,11 @@ graphite_create_new_loop_guard (sese region, edge entry_edge,
- PARAMS_INDEX connects the cloog parameters with the gimple parameters in
the sese region. */
static edge
translate_clast_for_loop (sese region, loop_p context_loop, struct clast_for *stmt, edge next_e,
htab_t rename_map, VEC (tree, heap) **newivs,
htab_t newivs_index, htab_t bb_pbb_mapping, int level,
htab_t params_index)
translate_clast_for_loop (sese region, loop_p context_loop,
struct clast_for *stmt, edge next_e,
htab_t rename_map, VEC (tree, heap) **newivs,
htab_t newivs_index, htab_t bb_pbb_mapping,
int level, htab_t params_index)
{
struct loop *loop = graphite_create_new_loop (region, next_e, stmt,
context_loop, newivs,
......@@ -858,8 +859,8 @@ translate_clast_for_loop (sese region, loop_p context_loop, struct clast_for *st
- PARAMS_INDEX connects the cloog parameters with the gimple parameters in
the sese region. */
static edge
translate_clast_for (sese region, loop_p context_loop, struct clast_for *stmt, edge next_e,
htab_t rename_map, VEC (tree, heap) **newivs,
translate_clast_for (sese region, loop_p context_loop, struct clast_for *stmt,
edge next_e, htab_t rename_map, VEC (tree, heap) **newivs,
htab_t newivs_index, htab_t bb_pbb_mapping, int level,
htab_t params_index)
{
......@@ -875,7 +876,8 @@ translate_clast_for (sese region, loop_p context_loop, struct clast_for *stmt, e
eq_rename_map_elts, free);
htab_traverse (rename_map, copy_renames, before_guard);
next_e = translate_clast_for_loop (region, context_loop, stmt, true_e, rename_map, newivs,
next_e = translate_clast_for_loop (region, context_loop, stmt, true_e,
rename_map, newivs,
newivs_index, bb_pbb_mapping, level,
params_index);
......
......@@ -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;
}
......
! { dg-options "-O2 -fgraphite-identity -fno-loop-block -fno-loop-interchange -fno-loop-strip-mine" }
MODULE beta_gamma_psi
INTEGER, PARAMETER :: dp=KIND(0.0D0)
CONTAINS
FUNCTION basym () RESULT(fn_val)
REAL(dp) :: b0(21), bsum, d(21)
DO n = 2, num, 2
DO i = n, np1
b0(1) = 1
DO m = 2, i
mm1 = m - 1
DO j = 1, mm1
bsum = bsum + b0(j)
END DO
b0(m) = bsum
END DO
d(i) = -b0(i)
END DO
sum = sum + d(n)
END DO
fn_val = sum
END FUNCTION basym
END MODULE beta_gamma_psi
! { dg-options "-fgraphite-identity -O2" }
! { dg-options "-O2 -fgraphite-identity -fno-loop-block -fno-loop-interchange -fno-loop-strip-mine" }
MODULE beta_gamma_psi
INTEGER, PARAMETER :: dp=KIND(0.0D0)
......
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