diff options
author | Sebastian Pop <sebastian.pop@amd.com> | 2009-11-25 05:24:14 +0000 |
---|---|---|
committer | Sebastian Pop <spop@gcc.gnu.org> | 2009-11-25 05:24:14 +0000 |
commit | 8e6ef139122f2f2209b7cde869b36de3f68dc82f (patch) | |
tree | 43aa80487a924b18f9032cc266bc872122717ff4 /gcc | |
parent | e6dd91b2baa1f73acdd1d6063abe18d3a6942b0d (diff) | |
download | gcc-8e6ef139122f2f2209b7cde869b36de3f68dc82f.tar.gz |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog.graphite | 18 | ||||
-rw-r--r-- | gcc/cfgloop.c | 1 | ||||
-rw-r--r-- | gcc/cfgloop.h | 4 | ||||
-rw-r--r-- | gcc/graphite-clast-to-gimple.c | 79 | ||||
-rw-r--r-- | gcc/graphite-clast-to-gimple.h | 1 | ||||
-rw-r--r-- | gcc/graphite-sese-to-poly.c | 40 | ||||
-rw-r--r-- | gcc/graphite.c | 16 |
7 files changed, 88 insertions, 71 deletions
diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite index e26c71769f1..a4f2ed06623 100644 --- a/gcc/ChangeLog.graphite +++ b/gcc/ChangeLog.graphite @@ -1,5 +1,23 @@ 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 gcc.dg/graphite/graphite.exp. diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c index b9af098d070..0f6e797329c 100644 --- a/gcc/cfgloop.c +++ b/gcc/cfgloop.c @@ -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; } diff --git a/gcc/cfgloop.h b/gcc/cfgloop.h index 4abdf8bfe15..764520711fd 100644 --- a/gcc/cfgloop.h +++ b/gcc/cfgloop.h @@ -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. */ diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c index 795bb6a678b..693e61c2a43 100644 --- a/gcc/graphite-clast-to-gimple.c +++ b/gcc/graphite-clast-to-gimple.c @@ -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 diff --git a/gcc/graphite-clast-to-gimple.h b/gcc/graphite-clast-to-gimple.h index e0ae6eedb3d..3f25872b61b 100644 --- a/gcc/graphite-clast-to-gimple.h +++ b/gcc/graphite-clast-to-gimple.h @@ -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. */ diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c index ac8c0242e84..8adffce20c3 100644 --- a/gcc/graphite-sese-to-poly.c +++ b/gcc/graphite-sese-to-poly.c @@ -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); diff --git a/gcc/graphite.c b/gcc/graphite.c index 8cb61d2c36e..291a1fea4b5 100644 --- a/gcc/graphite.c +++ b/gcc/graphite.c @@ -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. */ |