2009-10-14 Sebastian Pop <sebastian.pop@amd.com>
+ * graphite-blocking.c (pbb_do_strip_mine): Removed.
+ (lst_do_strip_mine_loop): New.
+ (lst_do_strip_mine): New.
+ (scop_do_strip_mine): Call lst_do_strip_mine.
+ * graphite-poly.h (lst_add_loop_under_loop): New.
+ (lst_find_first_pbb): New.
+
+2009-10-14 Sebastian Pop <sebastian.pop@amd.com>
+
* graphite-poly.c (loop_to_lst): Fix LST creation.
2009-10-14 Tobias Grosser <grosser@fim.uni-passau.de>
return res;
}
-/* Strip mines all the loops around PBB. Nothing profitable in all this:
- this is just a driver function. */
+/* Strip-mines all the loops of LST that are considered profitable to
+ strip-mine. Return true if it did strip-mined some loops. */
static bool
-pbb_do_strip_mine (poly_bb_p pbb)
+lst_do_strip_mine_loop (lst_p lst, int depth)
{
- graphite_dim_t s_dim;
+ int i;
+ lst_p l;
int stride = PARAM_VALUE (PARAM_LOOP_BLOCK_TILE_SIZE);
- bool transform_done = false;
+ poly_bb_p pbb;
- for (s_dim = 0; s_dim < pbb_nb_dynamic_scattering_transform (pbb); s_dim++)
- if (pbb_strip_mine_profitable_p (pbb, psct_dynamic_dim (pbb, s_dim),
- stride))
- {
- ppl_dimension_type d = psct_dynamic_dim (pbb, s_dim);
- transform_done |= pbb_strip_mine_time_depth (pbb, d, stride);
- s_dim++;
- }
+ if (!lst)
+ return false;
- return transform_done;
+ if (LST_LOOP_P (lst))
+ {
+ bool res = false;
+
+ for (i = 0; VEC_iterate (lst_p, LST_SEQ (lst), i, l); i++)
+ res |= lst_do_strip_mine_loop (l, depth);
+
+ return res;
+ }
+
+ pbb = LST_PBB (lst);
+ return pbb_strip_mine_time_depth (pbb, psct_dynamic_dim (pbb, depth),
+ stride);
}
+/* Strip-mines all the loops of LST that are considered profitable to
+ strip-mine. Return true if it did strip-mined some loops. */
+
+static bool
+lst_do_strip_mine (lst_p lst)
+{
+ int i;
+ lst_p l;
+ bool res = false;
+ int stride = PARAM_VALUE (PARAM_LOOP_BLOCK_TILE_SIZE);
+
+ if (!lst
+ || !LST_LOOP_P (lst))
+ return false;
+
+ for (i = 0; VEC_iterate (lst_p, LST_SEQ (lst), i, l); i++)
+ res |= lst_do_strip_mine (l);
+
+ if (pbb_strip_mine_profitable_p (LST_PBB (lst_find_first_pbb (lst)),
+ lst_depth (lst), stride))
+ {
+ res |= lst_do_strip_mine_loop (lst, lst_depth (lst));
+ lst_add_loop_under_loop (lst);
+ }
+
+ return res;
+}
+
+
/* Strip mines all the loops in SCOP. Nothing profitable in all this:
this is just a driver function. */
bool
scop_do_strip_mine (scop_p scop)
{
- poly_bb_p pbb;
- int i;
bool transform_done = false;
store_scattering (scop);
- for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb); i++)
- transform_done |= pbb_do_strip_mine (pbb);
+ transform_done = lst_do_strip_mine (SCOP_TRANSFORMED_SCHEDULE (scop));
if (!transform_done)
return false;
return false;
}
- return true;
+ return transform_done;
}
#endif
return new_lst_stmt (LST_PBB (lst));
}
+/* Adds a new loop under the loop LST. */
+
+static inline void
+lst_add_loop_under_loop (lst_p lst)
+{
+ VEC (lst_p, heap) *seq = VEC_alloc (lst_p, heap, 1);
+ lst_p l = new_lst_loop (LST_SEQ (lst));
+
+ gcc_assert (LST_LOOP_P (lst));
+
+ LST_LOOP_FATHER (l) = lst;
+ VEC_quick_push (lst_p, seq, l);
+ LST_SEQ (lst) = seq;
+}
+
/* Returns the loop depth of LST. */
static inline int
return loop;
}
+/* Return the LST node corresponding to PBB. */
+
+static inline lst_p
+lst_find_first_pbb (lst_p lst)
+{
+ int i;
+ lst_p l;
+
+ if (!lst)
+ return NULL;
+
+ if (LST_LOOP_P (lst))
+ for (i = 0; VEC_iterate (lst_p, LST_SEQ (lst), i, l); i++)
+ {
+ lst_p res = lst_find_first_pbb (l);
+ if (res)
+ return res;
+ }
+
+ return lst;
+}
/* A SCOP is a Static Control Part of the program, simple enough to be
represented in polyhedral form. */