summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog.graphite14
-rw-r--r--gcc/graphite-clast-to-gimple.c151
-rw-r--r--gcc/graphite-clast-to-gimple.h1
-rw-r--r--gcc/graphite.c20
4 files changed, 82 insertions, 104 deletions
diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index 733d35b94b6..4da7e865a05 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,4 +1,16 @@
-2009-10-20 Li Feng <nemokingdom@gmail.com>
+2009-10-26 Sebastian Pop <sebastian.pop@amd.com>
+
+ * graphite-clast-to-gimple.c (find_pbb_via_hash): Moved up.
+ (dependency_in_loop_p): Same.
+ (translate_clast): Do not use loop->aux. Initialize
+ loop->can_be_parallel.
+ (mark_loops_parallel): Removed.
+ * graphite-clast-to-gimple.h (mark_loops_parallel): Removed.
+ * graphite.c (free_aux_in_new_loops): Removed.
+ (graphite_finalize): Do not call free_aux_in_new_loops.
+ (graphite_transform_loops): Do not call mark_loops_parallel.
+
+2009-10-26 Li Feng <nemokingdom@gmail.com>
* graphite-clast-to-gimple.c (get_stmtfor_depth): Removed.
(translate_clast): Pass an extra parameter LEVEL.
diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c
index 05d3e2f61a3..96fb4318e39 100644
--- a/gcc/graphite-clast-to-gimple.c
+++ b/gcc/graphite-clast-to-gimple.c
@@ -558,6 +558,60 @@ mark_bb_with_pbb (poly_bb_p pbb, basic_block bb, htab_t bb_pbb_mapping)
*x = new_bb_pbb_def (bb, pbb);
}
+/* Find BB's related poly_bb_p in hash table BB_PBB_MAPPING. */
+
+static poly_bb_p
+find_pbb_via_hash (htab_t bb_pbb_mapping, basic_block bb)
+{
+ bb_pbb_def tmp;
+ PTR *slot;
+
+ tmp.bb = bb;
+ slot = htab_find_slot (bb_pbb_mapping, &tmp, NO_INSERT);
+
+ if (slot && *slot)
+ return ((bb_pbb_def *) *slot)->pbb;
+
+ return NULL;
+}
+
+/* Check data dependency in LOOP at scattering level LEVEL.
+ BB_PBB_MAPPING is a basic_block and it's related poly_bb_p
+ mapping. */
+
+static bool
+dependency_in_loop_p (loop_p loop, htab_t bb_pbb_mapping, int level)
+{
+ unsigned i,j;
+ basic_block *bbs = get_loop_body_in_dom_order (loop);
+
+ for (i = 0; i < loop->num_nodes; i++)
+ {
+ poly_bb_p pbb1 = find_pbb_via_hash (bb_pbb_mapping, bbs[i]);
+
+ if (pbb1 == NULL)
+ continue;
+
+ for (j = 0; j < loop->num_nodes; j++)
+ {
+ poly_bb_p pbb2 = find_pbb_via_hash (bb_pbb_mapping, bbs[j]);
+
+ if (pbb2 == NULL)
+ continue;
+
+ if (dependency_between_pbbs_p (pbb1, pbb2, level))
+ {
+ free (bbs);
+ return true;
+ }
+ }
+ }
+
+ free (bbs);
+
+ return false;
+}
+
/* Translates a CLAST statement STMT to GCC representation in the
context of a SESE.
@@ -617,10 +671,6 @@ translate_clast (sese region, struct loop *context_loop,
edge to_body = single_succ_edge (loop->header);
basic_block after = to_body->dest;
- loop->aux = XNEW (int);
- /* Pass scattering level information of the new loop by LOOP->AUX. */
- *((int *)(loop->aux)) = get_scattering_level (level);
-
/* Create a basic block for loop close phi nodes. */
last_e = single_succ_edge (split_edge (last_e));
@@ -636,6 +686,11 @@ translate_clast (sese region, struct loop *context_loop,
defined in loop's body. */
insert_loop_close_phis (rename_map, loop);
+ if (flag_loop_parallelize_all
+ && !dependency_in_loop_p (loop, bb_pbb_mapping,
+ get_scattering_level (level)))
+ loop->can_be_parallel = true;
+
recompute_all_dominators ();
graphite_verify ();
return translate_clast (region, context_loop, stmt->next, last_e,
@@ -1154,89 +1209,21 @@ gloog (scop_p scop, htab_t bb_pbb_mapping)
cloog_program_free (pc.prog);
timevar_pop (TV_GRAPHITE_CODE_GEN);
- return true;
-}
-
-
-
-/* Find BB's related poly_bb_p in hash table BB_PBB_MAPPING. */
-
-static poly_bb_p
-find_pbb_via_hash (htab_t bb_pbb_mapping, basic_block bb)
-{
- bb_pbb_def tmp;
- PTR *slot;
-
- tmp.bb = bb;
- slot = htab_find_slot (bb_pbb_mapping, &tmp, NO_INSERT);
-
- if (slot && *slot)
- return ((bb_pbb_def *) *slot)->pbb;
-
- return NULL;
-}
-
-/* Check data dependency in LOOP. BB_PBB_MAPPING is a basic_block and
- it's related poly_bb_p mapping.
-*/
-
-static bool
-dependency_in_loop_p (loop_p loop, htab_t bb_pbb_mapping)
-{
- unsigned i,j;
- int level = 0;
- basic_block *bbs = get_loop_body_in_dom_order (loop);
-
- level = *((int *)(loop->aux));
-
- for (i = 0; i < loop->num_nodes; i++)
+ if (dump_file && (dump_flags & TDF_DETAILS))
{
- poly_bb_p pbb1 = find_pbb_via_hash (bb_pbb_mapping, bbs[i]);
-
- if (pbb1 == NULL)
- continue;
-
- for (j = 0; j < loop->num_nodes; j++)
- {
- poly_bb_p pbb2 = find_pbb_via_hash (bb_pbb_mapping, bbs[j]);
+ loop_p loop;
+ loop_iterator li;
+ int num_no_dependency = 0;
- if (pbb2 == NULL)
- continue;
+ FOR_EACH_LOOP (li, loop, 0)
+ if (loop->can_be_parallel)
+ num_no_dependency++;
- if (dependency_between_pbbs_p (pbb1, pbb2, level))
- {
- free (bbs);
- return true;
- }
- }
+ fprintf (dump_file, "\n%d loops carried no dependency.\n",
+ num_no_dependency);
}
- free (bbs);
-
- return false;
-}
-
-/* Mark loop as parallel if data dependency does not exist.
- BB_PBB_MAPPING is a basic_block and it's related poly_bb_p mapping.
-*/
-
-void mark_loops_parallel (htab_t bb_pbb_mapping)
-{
- loop_p loop;
- loop_iterator li;
- int num_no_dependency = 0;
-
- FOR_EACH_LOOP (li, loop, 0)
- 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);
+ return true;
}
#endif
diff --git a/gcc/graphite-clast-to-gimple.h b/gcc/graphite-clast-to-gimple.h
index cbbf875f142..85fb5e1f34d 100644
--- a/gcc/graphite-clast-to-gimple.h
+++ b/gcc/graphite-clast-to-gimple.h
@@ -41,7 +41,6 @@ extern cloog_prog_clast scop_to_clast (scop_p);
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);
/* Hash function for data base element BB_PBB. */
diff --git a/gcc/graphite.c b/gcc/graphite.c
index 291a1fea4b5..83d484aae56 100644
--- a/gcc/graphite.c
+++ b/gcc/graphite.c
@@ -220,22 +220,6 @@ 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. */
@@ -252,7 +236,6 @@ graphite_finalize (bool need_cfg_cleanup_p)
cloog_finalize ();
free_original_copy_tables ();
- free_aux_in_new_loops ();
if (dump_file && dump_flags)
print_loops (dump_file, 3);
@@ -302,9 +285,6 @@ graphite_transform_loops (void)
}
}
- if (flag_loop_parallelize_all)
- mark_loops_parallel (bb_pbb_mapping);
-
htab_delete (bb_pbb_mapping);
free_scops (scops);
graphite_finalize (need_cfg_cleanup_p);