Commit 2c7a7f46 by Sebastian Pop

[multiple changes]

2008-10-15  Jan Sjodin  <jan.sjodin@amd.com>
    	    Harsha Jagasia  <harsha.jagasia@amd.com>

	PR tree-optimization/37485
	* graphite.c (gmp_cst_to_tree): Moved.
	(iv_stack_entry_is_constant): New.
	(iv_stack_entry_is_iv): New.
	(loop_iv_stack_push): Renamed to loop_iv_stack_push_iv.
	(loop_iv_stack_insert_constant): New.
	(loop_iv_stack_pop): Use new datatpype.
	(loop_iv_stack_get_iv): Same.
	(loop_iv_stack_get_iv_from_name): Same.
	(loop_iv_stack_debug): Renamed to debug_loop_iv_stack.
	(loop_iv_stack_patch_for_consts): New.
	(loop_iv_stack_remove_constants): New.
	(graphite_create_new_loop): Use loop_iv_stack_push_iv.
	(translate_clast): Call loop_iv_stack_patch_for_consts and
	loop_iv_stack_remove_constants.
	(gloog): Use new datatype.  Redirect construction edge to end
	block to avoid accidental deletion.
	* graphite.h (enum iv_stack_entry_kind): New.  Tag for data in
	iv stack entry.
	(union iv_stack_entry_data): New.  Data in iv stack entry.
	(struct iv_stack_entry): New.  Datatype for iv stack entries.

2008-10-15  Sebastian Pop  <sebastian.pop@amd.com>

	* tree-data-ref.c (stmt_simple_memref_p): Fix memleak.
	* graphite.c (free_scop): Same.
	(build_scops): Same.
	(free_scattering): New.
	(build_cloog_prog): Call free_scattering.
	(patch_phis_for_virtual_defs): Fix memleak.
	(graphite_trans_bb_strip_mine): Same.
	(limit_scops): Same.

From-SVN: r141143
parent 575da9be
2008-10-15 Jan Sjodin <jan.sjodin@amd.com>
Harsha Jagasia <harsha.jagasia@amd.com>
PR tree-optimization/37485
* graphite.c (gmp_cst_to_tree): Moved.
(iv_stack_entry_is_constant): New.
(iv_stack_entry_is_iv): New.
(loop_iv_stack_push): Renamed to loop_iv_stack_push_iv.
(loop_iv_stack_insert_constant): New.
(loop_iv_stack_pop): Use new datatpype.
(loop_iv_stack_get_iv): Same.
(loop_iv_stack_get_iv_from_name): Same.
(loop_iv_stack_debug): Renamed to debug_loop_iv_stack.
(loop_iv_stack_patch_for_consts): New.
(loop_iv_stack_remove_constants): New.
(graphite_create_new_loop): Use loop_iv_stack_push_iv.
(translate_clast): Call loop_iv_stack_patch_for_consts and
loop_iv_stack_remove_constants.
(gloog): Use new datatype. Redirect construction edge to end
block to avoid accidental deletion.
* graphite.h (enum iv_stack_entry_kind): New. Tag for data in
iv stack entry.
(union iv_stack_entry_data): New. Data in iv stack entry.
(struct iv_stack_entry): New. Datatype for iv stack entries.
2008-10-15 Sebastian Pop <sebastian.pop@amd.com>
* tree-data-ref.c (stmt_simple_memref_p): Fix memleak.
* graphite.c (free_scop): Same.
(build_scops): Same.
(free_scattering): New.
(build_cloog_prog): Call free_scattering.
(patch_phis_for_virtual_defs): Fix memleak.
(graphite_trans_bb_strip_mine): Same.
(limit_scops): Same.
2008-10-15 Sebastian Pop <sebastian.pop@amd.com> 2008-10-15 Sebastian Pop <sebastian.pop@amd.com>
Harsha Jagasia <harsha.jagasia@amd.com> Harsha Jagasia <harsha.jagasia@amd.com>
......
...@@ -60,6 +60,14 @@ along with GCC; see the file COPYING3. If not see ...@@ -60,6 +60,14 @@ along with GCC; see the file COPYING3. If not see
static VEC (scop_p, heap) *current_scops; static VEC (scop_p, heap) *current_scops;
/* Converts a GMP constant V to a tree and returns it. */
static tree
gmp_cst_to_tree (Value v)
{
return build_int_cst (integer_type_node, value_get_si (v));
}
/* Debug the list of old induction variables for this SCOP. */ /* Debug the list of old induction variables for this SCOP. */
void void
...@@ -95,24 +103,62 @@ debug_loop_vec (graphite_bb_p gb) ...@@ -95,24 +103,62 @@ debug_loop_vec (graphite_bb_p gb)
fprintf (stderr, "\n"); fprintf (stderr, "\n");
} }
/* Returns true if stack ENTRY is a constant. */
static bool
iv_stack_entry_is_constant (iv_stack_entry *entry)
{
return entry->kind == iv_stack_entry_const;
}
/* Returns true if stack ENTRY is an induction variable. */
static bool
iv_stack_entry_is_iv (iv_stack_entry *entry)
{
return entry->kind == iv_stack_entry_iv;
}
/* Push (IV, NAME) on STACK. */ /* Push (IV, NAME) on STACK. */
static void static void
loop_iv_stack_push (loop_iv_stack stack, tree iv, const char *name) loop_iv_stack_push_iv (loop_iv_stack stack, tree iv, const char *name)
{ {
iv_stack_entry *entry = XNEW (iv_stack_entry);
name_tree named_iv = XNEW (struct name_tree); name_tree named_iv = XNEW (struct name_tree);
named_iv->t = iv; named_iv->t = iv;
named_iv->name = name; named_iv->name = name;
VEC_safe_push (name_tree, heap, *stack, named_iv);
entry->kind = iv_stack_entry_iv;
entry->data.iv = named_iv;
VEC_safe_push (iv_stack_entry_p, heap, *stack, entry);
}
/* Inserts a CONSTANT in STACK at INDEX. */
static void
loop_iv_stack_insert_constant (loop_iv_stack stack, int index,
tree constant)
{
iv_stack_entry *entry = XNEW (iv_stack_entry);
entry->kind = iv_stack_entry_const;
entry->data.constant = constant;
VEC_safe_insert (iv_stack_entry_p, heap, *stack, index, entry);
} }
/* Pops an element out of STACK. */ /* Pops and frees an element out of STACK. */
static void static void
loop_iv_stack_pop (loop_iv_stack stack) loop_iv_stack_pop (loop_iv_stack stack)
{ {
VEC_pop (name_tree, *stack); iv_stack_entry_p entry = VEC_pop (iv_stack_entry_p, *stack);
free (entry->data.iv);
free (entry);
} }
/* Get the IV at INDEX in STACK. */ /* Get the IV at INDEX in STACK. */
...@@ -120,9 +166,14 @@ loop_iv_stack_pop (loop_iv_stack stack) ...@@ -120,9 +166,14 @@ loop_iv_stack_pop (loop_iv_stack stack)
static tree static tree
loop_iv_stack_get_iv (loop_iv_stack stack, int index) loop_iv_stack_get_iv (loop_iv_stack stack, int index)
{ {
name_tree named_iv = VEC_index (name_tree, *stack, index); iv_stack_entry_p entry = VEC_index (iv_stack_entry_p, *stack, index);
tree result = NULL;
if (entry->kind != iv_stack_entry_const)
result = entry->data.iv->t;
return named_iv->t; return result;
} }
/* Get the IV from its NAME in STACK. */ /* Get the IV from its NAME in STACK. */
...@@ -131,11 +182,14 @@ static tree ...@@ -131,11 +182,14 @@ static tree
loop_iv_stack_get_iv_from_name (loop_iv_stack stack, const char* name) loop_iv_stack_get_iv_from_name (loop_iv_stack stack, const char* name)
{ {
int i; int i;
name_tree iv; iv_stack_entry_p entry;
for (i = 0; VEC_iterate (name_tree, *stack, i, iv); i++) for (i = 0; VEC_iterate (iv_stack_entry_p, *stack, i, entry); i++)
{
name_tree iv = entry->data.iv;
if (!strcmp (name, iv->name)) if (!strcmp (name, iv->name))
return iv->t; return iv->t;
}
return NULL; return NULL;
} }
...@@ -143,27 +197,102 @@ loop_iv_stack_get_iv_from_name (loop_iv_stack stack, const char* name) ...@@ -143,27 +197,102 @@ loop_iv_stack_get_iv_from_name (loop_iv_stack stack, const char* name)
/* Prints on stderr the contents of STACK. */ /* Prints on stderr the contents of STACK. */
void void
loop_iv_stack_debug (loop_iv_stack stack) debug_loop_iv_stack (loop_iv_stack stack)
{ {
int i; int i;
name_tree iv; iv_stack_entry_p entry;
bool first = true; bool first = true;
fprintf (stderr, "("); fprintf (stderr, "(");
for (i = 0; VEC_iterate (name_tree, *stack, i, iv); i++) for (i = 0; VEC_iterate (iv_stack_entry_p, *stack, i, entry); i++)
{ {
if (first) if (first)
first = false; first = false;
else else
fprintf (stderr, " "); fprintf (stderr, " ");
if (iv_stack_entry_is_iv (entry))
{
name_tree iv = entry->data.iv;
fprintf (stderr, "%s:", iv->name); fprintf (stderr, "%s:", iv->name);
print_generic_expr (stderr, iv->t, 0); print_generic_expr (stderr, iv->t, 0);
} }
else
{
tree constant = entry->data.constant;
print_generic_expr (stderr, constant, 0);
fprintf (stderr, ":");
print_generic_expr (stderr, constant, 0);
}
}
fprintf (stderr, ")\n"); fprintf (stderr, ")\n");
} }
/* Frees STACK. */
static void
free_loop_iv_stack (loop_iv_stack stack)
{
int i;
iv_stack_entry_p entry;
for (i = 0; VEC_iterate (iv_stack_entry_p, *stack, i, entry); i++)
{
free (entry->data.iv);
free (entry);
}
VEC_free (iv_stack_entry_p, heap, *stack);
}
/* Inserts constants derived from the USER_STMT argument list into the
STACK. This is needed to map old ivs to constants when loops have
been eliminated. */
static void
loop_iv_stack_patch_for_consts (loop_iv_stack stack,
struct clast_user_stmt *user_stmt)
{
struct clast_stmt *t;
int index = 0;
for (t = user_stmt->substitutions; t; t = t->next)
{
struct clast_term *term = (struct clast_term*)
((struct clast_assignment *)t)->RHS;
/* FIXME: What should be done with expr_bin, expr_red? */
if (((struct clast_assignment *)t)->RHS->type == expr_term
&& !term->var)
{
tree value = gmp_cst_to_tree (term->val);
loop_iv_stack_insert_constant (stack, index, value);
}
index = index + 1;
}
}
/* Removes all constants in the iv STACK. */
static void
loop_iv_stack_remove_constants (loop_iv_stack stack)
{
int i;
iv_stack_entry *entry;
for (i = 0; VEC_iterate (iv_stack_entry_p, *stack, i, entry);)
{
if (iv_stack_entry_is_constant (entry))
{
free (VEC_index (iv_stack_entry_p, *stack, i));
VEC_ordered_remove (iv_stack_entry_p, *stack, i);
}
else
i++;
}
}
/* In SCOP, get the induction variable from NAME. OLD is the original /* In SCOP, get the induction variable from NAME. OLD is the original
loop that contained the definition of NAME. */ loop that contained the definition of NAME. */
...@@ -939,6 +1068,7 @@ free_scop (scop_p scop) ...@@ -939,6 +1068,7 @@ free_scop (scop_p scop)
int i; int i;
name_tree p; name_tree p;
struct graphite_bb *gb; struct graphite_bb *gb;
name_tree iv;
for (i = 0; VEC_iterate (graphite_bb_p, SCOP_BBS (scop), i, gb); i++) for (i = 0; VEC_iterate (graphite_bb_p, SCOP_BBS (scop), i, gb); i++)
free_graphite_bb (gb); free_graphite_bb (gb);
...@@ -947,6 +1077,9 @@ free_scop (scop_p scop) ...@@ -947,6 +1077,9 @@ free_scop (scop_p scop)
BITMAP_FREE (SCOP_BBS_B (scop)); BITMAP_FREE (SCOP_BBS_B (scop));
BITMAP_FREE (SCOP_LOOPS (scop)); BITMAP_FREE (SCOP_LOOPS (scop));
VEC_free (loop_p, heap, SCOP_LOOP_NEST (scop)); VEC_free (loop_p, heap, SCOP_LOOP_NEST (scop));
for (i = 0; VEC_iterate (name_tree, SCOP_OLDIVS (scop), i, iv); i++)
free (iv);
VEC_free (name_tree, heap, SCOP_OLDIVS (scop)); VEC_free (name_tree, heap, SCOP_OLDIVS (scop));
for (i = 0; VEC_iterate (name_tree, SCOP_PARAMS (scop), i, p); i++) for (i = 0; VEC_iterate (name_tree, SCOP_PARAMS (scop), i, p); i++)
...@@ -1688,6 +1821,7 @@ build_scops (void) ...@@ -1688,6 +1821,7 @@ build_scops (void)
build_scops_1 (single_succ (ENTRY_BLOCK_PTR), &tmp_scops, loop); build_scops_1 (single_succ (ENTRY_BLOCK_PTR), &tmp_scops, loop);
create_sese_edges (tmp_scops); create_sese_edges (tmp_scops);
build_graphite_scops (tmp_scops); build_graphite_scops (tmp_scops);
VEC_free (sd_region, heap, tmp_scops);
} }
/* Gather the basic blocks belonging to the SCOP. */ /* Gather the basic blocks belonging to the SCOP. */
...@@ -2988,14 +3122,6 @@ build_scop_data_accesses (scop_p scop) ...@@ -2988,14 +3122,6 @@ build_scop_data_accesses (scop_p scop)
} }
} }
/* Converts a GMP constant value to a tree and returns it. */
static tree
gmp_cst_to_tree (Value v)
{
return build_int_cst (integer_type_node, value_get_si (v));
}
/* Returns the tree variable from the name NAME that was given in /* Returns the tree variable from the name NAME that was given in
Cloog representation. All the parameters are stored in PARAMS, and Cloog representation. All the parameters are stored in PARAMS, and
all the loop induction variables are stored in IVSTACK. all the loop induction variables are stored in IVSTACK.
...@@ -3250,7 +3376,7 @@ graphite_create_new_loop (scop_p scop, edge entry_edge, ...@@ -3250,7 +3376,7 @@ graphite_create_new_loop (scop_p scop, edge entry_edge,
&iv_before, outer ? outer &iv_before, outer ? outer
: entry_edge->src->loop_father); : entry_edge->src->loop_father);
loop_iv_stack_push (ivstack, iv_before, stmt->iterator); loop_iv_stack_push_iv (ivstack, iv_before, stmt->iterator);
return loop; return loop;
} }
...@@ -3347,8 +3473,9 @@ expand_scalar_variables_expr (tree type, tree op0, enum tree_code code, ...@@ -3347,8 +3473,9 @@ expand_scalar_variables_expr (tree type, tree op0, enum tree_code code,
tree op1, graphite_bb_p gbb, scop_p scop, tree op1, graphite_bb_p gbb, scop_p scop,
loop_p old_loop_father, loop_iv_stack ivstack) loop_p old_loop_father, loop_iv_stack ivstack)
{ {
if (TREE_CODE_CLASS (code) == tcc_constant if ((TREE_CODE_CLASS (code) == tcc_constant
&& code == INTEGER_CST) && code == INTEGER_CST)
|| TREE_CODE_CLASS (code) == tcc_reference)
return op0; return op0;
if (TREE_CODE_CLASS (code) == tcc_unary) if (TREE_CODE_CLASS (code) == tcc_unary)
...@@ -3596,8 +3723,11 @@ translate_clast (scop_p scop, struct loop *context_loop, ...@@ -3596,8 +3723,11 @@ translate_clast (scop_p scop, struct loop *context_loop,
mark_virtual_ops_in_bb (bb); mark_virtual_ops_in_bb (bb);
next_e = make_edge (bb, next_e = make_edge (bb,
context_loop ? context_loop->latch : EXIT_BLOCK_PTR, context_loop ? context_loop->latch : EXIT_BLOCK_PTR,
EDGE_FALLTHRU);; EDGE_FALLTHRU);
loop_iv_stack_patch_for_consts (ivstack,
(struct clast_user_stmt *) stmt);
graphite_rename_ivs (gbb, scop, old_loop_father, ivstack); graphite_rename_ivs (gbb, scop, old_loop_father, ivstack);
loop_iv_stack_remove_constants (ivstack);
return translate_clast (scop, context_loop, stmt->next, next_e, ivstack); return translate_clast (scop, context_loop, stmt->next, next_e, ivstack);
} }
...@@ -3643,6 +3773,22 @@ translate_clast (scop_p scop, struct loop *context_loop, ...@@ -3643,6 +3773,22 @@ translate_clast (scop_p scop, struct loop *context_loop,
gcc_unreachable (); gcc_unreachable ();
} }
/* Free the SCATTERING domain list. */
static void
free_scattering (CloogDomainList *scattering)
{
while (scattering)
{
CloogDomain *dom = cloog_domain (scattering);
CloogDomainList *next = cloog_next_domain (scattering);
cloog_domain_free (dom);
free (scattering);
scattering = next;
}
}
/* Build cloog program for SCoP. */ /* Build cloog program for SCoP. */
static void static void
...@@ -3725,6 +3871,7 @@ build_cloog_prog (scop_p scop) ...@@ -3725,6 +3871,7 @@ build_cloog_prog (scop_p scop)
/* Apply scattering. */ /* Apply scattering. */
cloog_program_scatter (prog, scattering); cloog_program_scatter (prog, scattering);
free_scattering (scattering);
/* Iterators corresponding to scalar dimensions have to be extracted. */ /* Iterators corresponding to scalar dimensions have to be extracted. */
cloog_names_scalarize (cloog_program_names (prog), nbs, cloog_names_scalarize (cloog_program_names (prog), nbs,
...@@ -3806,7 +3953,6 @@ debug_clast_stmt (struct clast_stmt *stmt) ...@@ -3806,7 +3953,6 @@ debug_clast_stmt (struct clast_stmt *stmt)
static struct clast_stmt * static struct clast_stmt *
find_transform (scop_p scop) find_transform (scop_p scop)
{ {
CloogProgram *prog;
struct clast_stmt *stmt; struct clast_stmt *stmt;
CloogOptions *options = set_cloog_options (); CloogOptions *options = set_cloog_options ();
...@@ -3820,14 +3966,14 @@ find_transform (scop_p scop) ...@@ -3820,14 +3966,14 @@ find_transform (scop_p scop)
fprintf (dump_file, "]\n"); fprintf (dump_file, "]\n");
} }
prog = cloog_program_generate (SCOP_PROG (scop), options); SCOP_PROG (scop) = cloog_program_generate (SCOP_PROG (scop), options);
stmt = cloog_clast_create (prog, options); stmt = cloog_clast_create (SCOP_PROG (scop), options);
if (dump_file && (dump_flags & TDF_DETAILS)) if (dump_file && (dump_flags & TDF_DETAILS))
{ {
fprintf (dump_file, "Cloog Output[\n"); fprintf (dump_file, "Cloog Output[\n");
pprint (dump_file, stmt, 0, options); pprint (dump_file, stmt, 0, options);
cloog_program_dump_cloog (dump_file, prog); cloog_program_dump_cloog (dump_file, SCOP_PROG (scop));
fprintf (dump_file, "]\n"); fprintf (dump_file, "]\n");
} }
...@@ -3964,6 +4110,8 @@ patch_phis_for_virtual_defs (void) ...@@ -3964,6 +4110,8 @@ patch_phis_for_virtual_defs (void)
gsi = gsi_for_stmt (phi); gsi = gsi_for_stmt (phi);
remove_phi_node (&gsi, false); remove_phi_node (&gsi, false);
} }
VEC_free (gimple, heap, virtual_phis);
} }
/* Mark the original loops of SCOP for removal, replacing their header /* Mark the original loops of SCOP for removal, replacing their header
...@@ -4132,9 +4280,10 @@ gloog (scop_p scop, struct clast_stmt *stmt) ...@@ -4132,9 +4280,10 @@ gloog (scop_p scop, struct clast_stmt *stmt)
{ {
edge new_scop_exit_edge = NULL; edge new_scop_exit_edge = NULL;
basic_block scop_exit = SCOP_EXIT (scop); basic_block scop_exit = SCOP_EXIT (scop);
VEC (tree, heap)* phi_args = VEC (tree, heap) *phi_args =
collect_scop_exit_phi_args (SESE_EXIT (SCOP_REGION (scop))); collect_scop_exit_phi_args (SESE_EXIT (SCOP_REGION (scop)));
VEC (name_tree, heap) *ivstack = VEC_alloc (name_tree, heap, 10); VEC (iv_stack_entry_p, heap) *ivstack =
VEC_alloc (iv_stack_entry_p, heap, 10);
edge construction_edge = SESE_ENTRY (SCOP_REGION (scop)); edge construction_edge = SESE_ENTRY (SCOP_REGION (scop));
basic_block old_scop_exit_idom = get_immediate_dominator (CDI_DOMINATORS, basic_block old_scop_exit_idom = get_immediate_dominator (CDI_DOMINATORS,
scop_exit); scop_exit);
...@@ -4145,10 +4294,13 @@ gloog (scop_p scop, struct clast_stmt *stmt) ...@@ -4145,10 +4294,13 @@ gloog (scop_p scop, struct clast_stmt *stmt)
return; return;
} }
redirect_edge_succ_nodup (construction_edge, EXIT_BLOCK_PTR);
new_scop_exit_edge = translate_clast (scop, new_scop_exit_edge = translate_clast (scop,
construction_edge->src->loop_father, construction_edge->src->loop_father,
stmt, construction_edge, &ivstack); stmt, construction_edge, &ivstack);
free_loop_iv_stack (&ivstack);
redirect_edge_succ (new_scop_exit_edge, scop_exit); redirect_edge_succ (new_scop_exit_edge, scop_exit);
if (!old_scop_exit_idom if (!old_scop_exit_idom
|| !dominated_by_p (CDI_DOMINATORS, SCOP_ENTRY (scop), || !dominated_by_p (CDI_DOMINATORS, SCOP_ENTRY (scop),
old_scop_exit_idom) old_scop_exit_idom)
...@@ -4165,6 +4317,7 @@ gloog (scop_p scop, struct clast_stmt *stmt) ...@@ -4165,6 +4317,7 @@ gloog (scop_p scop, struct clast_stmt *stmt)
delete_unreachable_blocks (); delete_unreachable_blocks ();
patch_phis_for_virtual_defs (); patch_phis_for_virtual_defs ();
patch_scop_exit_phi_args (new_scop_exit_edge, phi_args); patch_scop_exit_phi_args (new_scop_exit_edge, phi_args);
VEC_free (tree, heap, phi_args);
mark_old_loops (scop); mark_old_loops (scop);
remove_dead_loops (); remove_dead_loops ();
rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa); rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa);
...@@ -4416,7 +4569,6 @@ static void ...@@ -4416,7 +4569,6 @@ static void
get_lower_bound (CloogMatrix *domain, int loop, Value lower_bound_result) get_lower_bound (CloogMatrix *domain, int loop, Value lower_bound_result)
{ {
int lower_bound_row = get_lower_bound_row (domain, loop); int lower_bound_row = get_lower_bound_row (domain, loop);
value_init (lower_bound_result);
value_assign (lower_bound_result, value_assign (lower_bound_result,
domain->p[lower_bound_row][const_column_index(domain)]); domain->p[lower_bound_row][const_column_index(domain)]);
} }
...@@ -4427,7 +4579,6 @@ static void ...@@ -4427,7 +4579,6 @@ static void
get_upper_bound (CloogMatrix *domain, int loop, Value upper_bound_result) get_upper_bound (CloogMatrix *domain, int loop, Value upper_bound_result)
{ {
int upper_bound_row = get_upper_bound_row (domain, loop); int upper_bound_row = get_upper_bound_row (domain, loop);
value_init (upper_bound_result);
value_assign (upper_bound_result, value_assign (upper_bound_result,
domain->p[upper_bound_row][const_column_index(domain)]); domain->p[upper_bound_row][const_column_index(domain)]);
} }
...@@ -4450,7 +4601,6 @@ graphite_trans_bb_strip_mine (graphite_bb_p gb, int loop_depth, int stride) ...@@ -4450,7 +4601,6 @@ graphite_trans_bb_strip_mine (graphite_bb_p gb, int loop_depth, int stride)
Value old_lower_bound; Value old_lower_bound;
Value old_upper_bound; Value old_upper_bound;
gcc_assert (loop_depth <= gbb_nb_loops (gb) - 1); gcc_assert (loop_depth <= gbb_nb_loops (gb) - 1);
VEC_safe_insert (loop_p, heap, GBB_LOOPS (gb), loop_depth, NULL); VEC_safe_insert (loop_p, heap, GBB_LOOPS (gb), loop_depth, NULL);
...@@ -4470,13 +4620,9 @@ graphite_trans_bb_strip_mine (graphite_bb_p gb, int loop_depth, int stride) ...@@ -4470,13 +4620,9 @@ graphite_trans_bb_strip_mine (graphite_bb_p gb, int loop_depth, int stride)
for (row = 0; row < domain->NbRows; row++) for (row = 0; row < domain->NbRows; row++)
for (col = 0; col < domain->NbColumns; col++) for (col = 0; col < domain->NbColumns; col++)
if (col <= loop_depth) if (col <= loop_depth)
{
value_assign (new_domain->p[row][col], domain->p[row][col]); value_assign (new_domain->p[row][col], domain->p[row][col]);
}
else else
{
value_assign (new_domain->p[row][col + 1], domain->p[row][col]); value_assign (new_domain->p[row][col + 1], domain->p[row][col]);
}
/* /*
...@@ -4495,7 +4641,8 @@ graphite_trans_bb_strip_mine (graphite_bb_p gb, int loop_depth, int stride) ...@@ -4495,7 +4641,8 @@ graphite_trans_bb_strip_mine (graphite_bb_p gb, int loop_depth, int stride)
row = domain->NbRows; row = domain->NbRows;
/* Add outer loop. */ /* Add outer loop. */
value_init (old_lower_bound);
value_init (old_upper_bound);
get_lower_bound (new_domain, col_loop_old, old_lower_bound); get_lower_bound (new_domain, col_loop_old, old_lower_bound);
get_upper_bound (new_domain, col_loop_old, old_upper_bound); get_upper_bound (new_domain, col_loop_old, old_upper_bound);
...@@ -4504,6 +4651,7 @@ graphite_trans_bb_strip_mine (graphite_bb_p gb, int loop_depth, int stride) ...@@ -4504,6 +4651,7 @@ graphite_trans_bb_strip_mine (graphite_bb_p gb, int loop_depth, int stride)
value_set_si (new_domain->p[row][col_loop_strip], 1); value_set_si (new_domain->p[row][col_loop_strip], 1);
value_assign (new_domain->p[row][const_column_index (new_domain)], value_assign (new_domain->p[row][const_column_index (new_domain)],
old_lower_bound); old_lower_bound);
value_clear (old_lower_bound);
row++; row++;
...@@ -4524,12 +4672,10 @@ graphite_trans_bb_strip_mine (graphite_bb_p gb, int loop_depth, int stride) ...@@ -4524,12 +4672,10 @@ graphite_trans_bb_strip_mine (graphite_bb_p gb, int loop_depth, int stride)
Value strip_size_value; Value strip_size_value;
value_init (new_upper_bound); value_init (new_upper_bound);
value_init (strip_size_value); value_init (strip_size_value);
value_set_si (strip_size_value, (int) stride); value_set_si (strip_size_value, (int) stride);
value_pdivision (new_upper_bound, old_upper_bound, strip_size_value);
value_pdivision(new_upper_bound,old_upper_bound,strip_size_value);
value_add_int (new_upper_bound, new_upper_bound, 1); value_add_int (new_upper_bound, new_upper_bound, 1);
/* Set Upper Bound */ /* Set Upper Bound */
...@@ -4537,6 +4683,10 @@ graphite_trans_bb_strip_mine (graphite_bb_p gb, int loop_depth, int stride) ...@@ -4537,6 +4683,10 @@ graphite_trans_bb_strip_mine (graphite_bb_p gb, int loop_depth, int stride)
value_set_si (new_domain->p[row][col_loop_strip], -1); value_set_si (new_domain->p[row][col_loop_strip], -1);
value_assign (new_domain->p[row][const_column_index (new_domain)], value_assign (new_domain->p[row][const_column_index (new_domain)],
new_upper_bound); new_upper_bound);
value_clear (strip_size_value);
value_clear (old_upper_bound);
value_clear (new_upper_bound);
row++; row++;
} }
/* /*
...@@ -4983,6 +5133,7 @@ limit_scops (void) ...@@ -4983,6 +5133,7 @@ limit_scops (void)
create_sese_edges (tmp_scops); create_sese_edges (tmp_scops);
build_graphite_scops (tmp_scops); build_graphite_scops (tmp_scops);
VEC_free (sd_region, heap, tmp_scops);
} }
/* Perform a set of linear transforms on the loops of the current /* Perform a set of linear transforms on the loops of the current
......
...@@ -260,7 +260,7 @@ typedef struct name_tree ...@@ -260,7 +260,7 @@ typedef struct name_tree
{ {
tree t; tree t;
const char *name; const char *name;
struct loop* loop; struct loop *loop;
} *name_tree; } *name_tree;
DEF_VEC_P(name_tree); DEF_VEC_P(name_tree);
...@@ -340,8 +340,34 @@ extern void debug_clast_stmt (struct clast_stmt *); ...@@ -340,8 +340,34 @@ extern void debug_clast_stmt (struct clast_stmt *);
extern void debug_loop_vec (graphite_bb_p gb); extern void debug_loop_vec (graphite_bb_p gb);
extern void debug_oldivs (scop_p); extern void debug_oldivs (scop_p);
typedef VEC(name_tree, heap) **loop_iv_stack; /* Describes the type of an iv stack entry. */
extern void loop_iv_stack_debug (loop_iv_stack); typedef enum {
iv_stack_entry_unknown = 0,
iv_stack_entry_iv,
iv_stack_entry_const
} iv_stack_entry_kind;
/* Data contained in an iv stack entry. */
typedef union iv_stack_entry_data_union
{
name_tree iv;
tree constant;
} iv_stack_entry_data;
/* Datatype for loop iv stack entry. */
typedef struct iv_stack_entry_struct
{
iv_stack_entry_kind kind;
iv_stack_entry_data data;
} iv_stack_entry;
typedef iv_stack_entry *iv_stack_entry_p;
DEF_VEC_P(iv_stack_entry_p);
DEF_VEC_ALLOC_P(iv_stack_entry_p,heap);
typedef VEC(iv_stack_entry_p, heap) **loop_iv_stack;
extern void debug_loop_iv_stack (loop_iv_stack);
/* Return the number of gimple loops contained in SCOP. */ /* Return the number of gimple loops contained in SCOP. */
......
2008-10-15 Jan Sjodin <jan.sjodin@amd.com>
Harsha Jagasia <harsha.jagasia@amd.com>
PR tree-optimization/37485
* gcc.dg/graphite/pr37485.c: New.
2008-10-15 Sebastian Pop <sebastian.pop@amd.com> 2008-10-15 Sebastian Pop <sebastian.pop@amd.com>
Harsha Jagasia <harsha.jagasia@amd.com> Harsha Jagasia <harsha.jagasia@amd.com>
......
/* { dg-options "-O2 -floop-block -fdump-tree-graphite-all" } */
typedef unsigned char UChar;
typedef int Int32;
typedef unsigned int UInt32;
void fallbackSort ( UInt32* fmap,
UInt32* eclass,
Int32 nblock,
Int32 verb )
{
Int32 ftab[257];
Int32 ftabCopy[256];
Int32 H, i, j, k, l, r, cc, cc1;
Int32 nNotDone;
Int32 nBhtab;
UChar* eclass8 = (UChar*)eclass;
if (verb >= 4)
VPrintf0 ( " bucket sorting ...\n" );
for (i = 0; i < 257; i++) ftab[i] = 0;
for (i = 0; i < nblock; i++) ftab[eclass8[i]]++;
for (i = 0; i < 256; i++) ftabCopy[i] = ftab[i];
for (i = 1; i < 257; i++) ftab[i] += ftab[i-1];
for (i = 0; i < nblock; i++) {
j = eclass8[i] + ftab [i];
}
AssertH ( j < 256, 1005 );
}
/* { dg-final { scan-tree-dump-times "Loop blocked" 1 "graphite" { xfail *-*-* }} } */
...@@ -3311,13 +3311,14 @@ bool ...@@ -3311,13 +3311,14 @@ bool
stmt_simple_memref_p (struct loop *loop, gimple stmt, tree op) stmt_simple_memref_p (struct loop *loop, gimple stmt, tree op)
{ {
data_reference_p dr; data_reference_p dr;
bool res = true;
dr = create_data_ref (loop, op, stmt, true); dr = create_data_ref (loop, op, stmt, true);
if (!access_functions_are_affine_or_constant_p (dr, loop)) if (!access_functions_are_affine_or_constant_p (dr, loop))
return false; res = false;
free_data_ref (dr); free_data_ref (dr);
return true; return res;
} }
/* Initializes an equation for an OMEGA problem using the information /* Initializes an equation for an OMEGA problem using the information
......
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