summaryrefslogtreecommitdiff
path: root/gcc/graphite-isl-ast-to-gimple.c
diff options
context:
space:
mode:
authorromangareev <romangareev@138bc75d-0d04-0410-961f-82ee72b054a4>2014-07-23 06:52:14 +0000
committerromangareev <romangareev@138bc75d-0d04-0410-961f-82ee72b054a4>2014-07-23 06:52:14 +0000
commit1d56dd2b80f2a6268e4d197894736449b2ca9453 (patch)
treeae24c4ee3568a1ad4d27af51cb3852b9c9dba15a /gcc/graphite-isl-ast-to-gimple.c
parentb1682756e523d298b8e0522aa79c3bacbe70753f (diff)
downloadgcc-1d56dd2b80f2a6268e4d197894736449b2ca9453.tar.gz
gcc/
* graphite-isl-ast-to-gimple.c: (get_max_schedule_dimensions): New function. (extend_schedule): Likewise. (generate_isl_schedule): Add calling of extend_schedule and get_max_schedule_dimensions. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@212921 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/graphite-isl-ast-to-gimple.c')
-rw-r--r--gcc/graphite-isl-ast-to-gimple.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/gcc/graphite-isl-ast-to-gimple.c b/gcc/graphite-isl-ast-to-gimple.c
index e567cc67563..75cbfb575d4 100644
--- a/gcc/graphite-isl-ast-to-gimple.c
+++ b/gcc/graphite-isl-ast-to-gimple.c
@@ -685,12 +685,57 @@ generate_isl_context (scop_p scop)
return isl_ast_build_from_context (context_isl);
}
+/* Get the maximal number of schedule dimensions in the scop SCOP. */
+
+static
+int get_max_schedule_dimensions (scop_p scop)
+{
+ int i;
+ poly_bb_p pbb;
+ int schedule_dims = 0;
+
+ FOR_EACH_VEC_ELT (SCOP_BBS (scop), i, pbb)
+ {
+ int pbb_schedule_dims = isl_map_dim (pbb->transformed, isl_dim_out);
+ if (pbb_schedule_dims > schedule_dims)
+ schedule_dims = pbb_schedule_dims;
+ }
+
+ return schedule_dims;
+}
+
+/* Extend the schedule to NB_SCHEDULE_DIMS schedule dimensions.
+
+ For schedules with different dimensionality, the isl AST generator can not
+ define an order and will just randomly choose an order. The solution to this
+ problem is to extend all schedules to the maximal number of schedule
+ dimensions (using '0's for the remaining values). */
+
+static __isl_give isl_map *
+extend_schedule (__isl_take isl_map *schedule, int nb_schedule_dims)
+{
+ int tmp_dims = isl_map_dim (schedule, isl_dim_out);
+ schedule =
+ isl_map_add_dims (schedule, isl_dim_out, nb_schedule_dims - tmp_dims);
+ isl_val *zero =
+ isl_val_int_from_si (isl_map_get_ctx (schedule), 0);
+ int i;
+ for (i = tmp_dims; i < nb_schedule_dims; i++)
+ {
+ schedule =
+ isl_map_fix_val (schedule, isl_dim_out, i, isl_val_copy (zero));
+ }
+ isl_val_free (zero);
+ return schedule;
+}
+
/* Generates a schedule, which specifies an order used to
visit elements in a domain. */
static __isl_give isl_union_map *
generate_isl_schedule (scop_p scop)
{
+ int nb_schedule_dims = get_max_schedule_dimensions (scop);
int i;
poly_bb_p pbb;
isl_union_map *schedule_isl =
@@ -706,6 +751,7 @@ generate_isl_schedule (scop_p scop)
isl_map *bb_schedule = isl_map_copy (pbb->transformed);
bb_schedule = isl_map_intersect_domain (bb_schedule,
isl_set_copy (pbb->domain));
+ bb_schedule = extend_schedule (bb_schedule, nb_schedule_dims);
schedule_isl =
isl_union_map_union (schedule_isl,
isl_union_map_from_map (bb_schedule));