cfgloop.c (alloc_loop): Initialize loop->single_iv.
2009-10-22 Sebastian Pop <sebastian.pop@amd.com> * cfgloop.c (alloc_loop): Initialize loop->single_iv. * cfgloop.h (struct loop): New field single_iv. * graphite-clast-to-gimple.c (pbb_to_depth_to_oldiv): Do not use loop->aux anymore: use loop->single_iv. (graphite_loop_normal_form): Moved... (build_graphite_loop_normal_form): Removed. (gloog): Do not call build_graphite_loop_normal_form. (free_aux_in_new_loops): Moved... (mark_loops_parallel): Restructure. * graphite-clast-to-gimple.h (free_aux_in_new_loops): Do not declare. * graphite-sese-to-poly.c (graphite_loop_normal_form): ...here. (scop_canonicalize_loops): New. (build_poly_scop): Call scop_canonicalize_loops. * graphite.c (free_aux_in_new_loops): ...here. From-SVN: r154624
This commit is contained in:
parent
e6dd91b2ba
commit
8e6ef13912
7 changed files with 88 additions and 71 deletions
|
@ -1,3 +1,21 @@
|
|||
2009-10-22 Sebastian Pop <sebastian.pop@amd.com>
|
||||
|
||||
* cfgloop.c (alloc_loop): Initialize loop->single_iv.
|
||||
* cfgloop.h (struct loop): New field single_iv.
|
||||
|
||||
* graphite-clast-to-gimple.c (pbb_to_depth_to_oldiv): Do not use
|
||||
loop->aux anymore: use loop->single_iv.
|
||||
(graphite_loop_normal_form): Moved...
|
||||
(build_graphite_loop_normal_form): Removed.
|
||||
(gloog): Do not call build_graphite_loop_normal_form.
|
||||
(free_aux_in_new_loops): Moved...
|
||||
(mark_loops_parallel): Restructure.
|
||||
* graphite-clast-to-gimple.h (free_aux_in_new_loops): Do not declare.
|
||||
* graphite-sese-to-poly.c (graphite_loop_normal_form): ...here.
|
||||
(scop_canonicalize_loops): New.
|
||||
(build_poly_scop): Call scop_canonicalize_loops.
|
||||
* graphite.c (free_aux_in_new_loops): ...here.
|
||||
|
||||
2009-10-22 Sebastian Pop <sebastian.pop@amd.com>
|
||||
|
||||
* g++.dg/graphite/graphite.exp: Add the same rules as in
|
||||
|
|
|
@ -339,6 +339,7 @@ alloc_loop (void)
|
|||
loop->exits = GGC_CNEW (struct loop_exit);
|
||||
loop->exits->next = loop->exits->prev = loop->exits;
|
||||
loop->can_be_parallel = false;
|
||||
loop->single_iv = NULL_TREE;
|
||||
|
||||
return loop;
|
||||
}
|
||||
|
|
|
@ -160,6 +160,10 @@ struct GTY ((chain_next ("%h.next"))) loop {
|
|||
|
||||
/* True if the loop can be parallel. */
|
||||
bool can_be_parallel;
|
||||
|
||||
/* The single induction variable of the loop when the loop is in
|
||||
normal form. */
|
||||
tree single_iv;
|
||||
};
|
||||
|
||||
/* Flags for state of loop structure. */
|
||||
|
|
|
@ -76,7 +76,7 @@ pbb_to_depth_to_oldiv (poly_bb_p pbb, int depth)
|
|||
sese region = SCOP_REGION (PBB_SCOP (pbb));
|
||||
loop_p loop = gbb_loop_at_index (gbb, region, depth);
|
||||
|
||||
return (tree) loop->aux;
|
||||
return loop->single_iv;
|
||||
}
|
||||
|
||||
/* For a given scattering dimension, return the new induction variable
|
||||
|
@ -1109,43 +1109,6 @@ debug_generated_program (scop_p scop)
|
|||
print_generated_program (stderr, scop);
|
||||
}
|
||||
|
||||
/* A LOOP is in normal form for Graphite when it contains only one
|
||||
scalar phi node that defines the main induction variable of the
|
||||
loop, only one increment of the IV, and only one exit condition. */
|
||||
|
||||
static void
|
||||
graphite_loop_normal_form (loop_p loop)
|
||||
{
|
||||
struct tree_niter_desc niter;
|
||||
tree nit;
|
||||
gimple_seq stmts;
|
||||
edge exit = single_dom_exit (loop);
|
||||
|
||||
bool known_niter = number_of_iterations_exit (loop, exit, &niter, false);
|
||||
|
||||
/* At this point we should know the number of iterations, */
|
||||
gcc_assert (known_niter);
|
||||
|
||||
nit = force_gimple_operand (unshare_expr (niter.niter), &stmts, true,
|
||||
NULL_TREE);
|
||||
if (stmts)
|
||||
gsi_insert_seq_on_edge_immediate (loop_preheader_edge (loop), stmts);
|
||||
|
||||
loop->aux = canonicalize_loop_ivs (loop, &nit);
|
||||
}
|
||||
|
||||
/* Converts REGION to loop normal form: one induction variable per loop. */
|
||||
|
||||
static void
|
||||
build_graphite_loop_normal_form (sese region)
|
||||
{
|
||||
int i;
|
||||
loop_p loop;
|
||||
|
||||
for (i = 0; VEC_iterate (loop_p, SESE_LOOP_NEST (region), i, loop); i++)
|
||||
graphite_loop_normal_form (loop);
|
||||
}
|
||||
|
||||
/* GIMPLE Loop Generator: generates loops from STMT in GIMPLE form for
|
||||
the given SCOP. Return true if code generation succeeded.
|
||||
BB_PBB_MAPPING is a basic_block and it's related poly_bb_p mapping.
|
||||
|
@ -1173,7 +1136,6 @@ gloog (scop_p scop, htab_t bb_pbb_mapping)
|
|||
fprintf (dump_file, "\n");
|
||||
}
|
||||
|
||||
build_graphite_loop_normal_form (region);
|
||||
recompute_all_dominators ();
|
||||
graphite_verify ();
|
||||
|
||||
|
@ -1234,23 +1196,6 @@ find_pbb_via_hash (htab_t bb_pbb_mapping, basic_block bb)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/* Free loop->aux in newly created loops by translate_clast. */
|
||||
|
||||
void
|
||||
free_aux_in_new_loops (void)
|
||||
{
|
||||
loop_p loop;
|
||||
loop_iterator li;
|
||||
|
||||
FOR_EACH_LOOP (li, loop, 0)
|
||||
{
|
||||
if (!loop->aux)
|
||||
continue;
|
||||
free(loop->aux);
|
||||
loop->aux = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check data dependency in LOOP. BB_PBB_MAPPING is a basic_block and
|
||||
it's related poly_bb_p mapping.
|
||||
*/
|
||||
|
@ -1302,22 +1247,16 @@ void mark_loops_parallel (htab_t bb_pbb_mapping)
|
|||
int num_no_dependency = 0;
|
||||
|
||||
FOR_EACH_LOOP (li, loop, 0)
|
||||
{
|
||||
if (!loop->aux)
|
||||
continue;
|
||||
|
||||
if (!dependency_in_loop_p (loop, bb_pbb_mapping))
|
||||
{
|
||||
loop->can_be_parallel = true;
|
||||
num_no_dependency++;
|
||||
}
|
||||
}
|
||||
if (loop->aux
|
||||
&& !dependency_in_loop_p (loop, bb_pbb_mapping))
|
||||
{
|
||||
loop->can_be_parallel = true;
|
||||
num_no_dependency++;
|
||||
}
|
||||
|
||||
if (dump_file && (dump_flags & TDF_DETAILS))
|
||||
{
|
||||
fprintf (dump_file, "\n%d loops carried no dependency.\n",
|
||||
num_no_dependency);
|
||||
}
|
||||
fprintf (dump_file, "\n%d loops carried no dependency.\n",
|
||||
num_no_dependency);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -42,7 +42,6 @@ extern void debug_clast_stmt (struct clast_stmt *);
|
|||
extern void print_clast_stmt (FILE *, struct clast_stmt *);
|
||||
extern void debug_clast_name_indexes (htab_t);
|
||||
extern void mark_loops_parallel (htab_t);
|
||||
extern void free_aux_in_new_loops (void);
|
||||
|
||||
/* Hash function for data base element BB_PBB. */
|
||||
|
||||
|
|
|
@ -2822,6 +2822,45 @@ rewrite_commutative_reductions_out_of_ssa (sese region, sbitmap reductions)
|
|||
#endif
|
||||
}
|
||||
|
||||
/* A LOOP is in normal form for Graphite when it contains only one
|
||||
scalar phi node that defines the main induction variable of the
|
||||
loop, only one increment of the IV, and only one exit condition. */
|
||||
|
||||
static void
|
||||
graphite_loop_normal_form (loop_p loop)
|
||||
{
|
||||
struct tree_niter_desc niter;
|
||||
tree nit;
|
||||
gimple_seq stmts;
|
||||
edge exit = single_dom_exit (loop);
|
||||
|
||||
bool known_niter = number_of_iterations_exit (loop, exit, &niter, false);
|
||||
|
||||
/* At this point we should know the number of iterations, */
|
||||
gcc_assert (known_niter);
|
||||
|
||||
nit = force_gimple_operand (unshare_expr (niter.niter), &stmts, true,
|
||||
NULL_TREE);
|
||||
if (stmts)
|
||||
gsi_insert_seq_on_edge_immediate (loop_preheader_edge (loop), stmts);
|
||||
|
||||
loop->single_iv = canonicalize_loop_ivs (loop, &nit);
|
||||
}
|
||||
|
||||
/* Rewrite all the loops of SCOP in normal form: one induction
|
||||
variable per loop. */
|
||||
|
||||
static void
|
||||
scop_canonicalize_loops (scop_p scop)
|
||||
{
|
||||
loop_iterator li;
|
||||
loop_p loop;
|
||||
|
||||
FOR_EACH_LOOP (li, loop, 0)
|
||||
if (loop_in_sese_p (loop, SCOP_REGION (scop)))
|
||||
graphite_loop_normal_form (loop);
|
||||
}
|
||||
|
||||
/* Builds the polyhedral representation for a SESE region. */
|
||||
|
||||
bool
|
||||
|
@ -2843,6 +2882,7 @@ build_poly_scop (scop_p scop)
|
|||
if (nb_pbbs_in_loops (scop) == 0)
|
||||
return false;
|
||||
|
||||
scop_canonicalize_loops (scop);
|
||||
build_sese_loop_nests (region);
|
||||
build_sese_conditions (region);
|
||||
find_scop_parameters (scop);
|
||||
|
|
|
@ -220,6 +220,22 @@ graphite_initialize (void)
|
|||
return true;
|
||||
}
|
||||
|
||||
/* Free loop->aux in newly created loops by translate_clast. */
|
||||
|
||||
static void
|
||||
free_aux_in_new_loops (void)
|
||||
{
|
||||
loop_p loop;
|
||||
loop_iterator li;
|
||||
|
||||
FOR_EACH_LOOP (li, loop, 0)
|
||||
if (loop->aux)
|
||||
{
|
||||
free (loop->aux);
|
||||
loop->aux = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Finalize graphite: perform CFG cleanup when NEED_CFG_CLEANUP_P is
|
||||
true. */
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue