diff options
author | spop <spop@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-07-05 14:50:34 +0000 |
---|---|---|
committer | spop <spop@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-07-05 14:50:34 +0000 |
commit | a6ccb398e007eb4aa13d2374660a48f7a179f63e (patch) | |
tree | bb332b8bbbc0bb93e01d2b53950af05852a521d7 /gcc/graphite-blocking.c | |
parent | 75663c96c50e7826962cc18f60923a2772eff3ef (diff) | |
download | gcc-a6ccb398e007eb4aa13d2374660a48f7a179f63e.tar.gz |
Fix PR47654: Loop blocking should strip-mine at least two loops.
PR tree-optimization/47654
* graphite-blocking.c (pbb_strip_mine_time_depth): Do not return bool.
(lst_do_strip_mine_loop): Return an int.
(lst_do_strip_mine): Same.
(scop_do_strip_mine): Same.
(scop_do_block): Loop blocking should strip-mine at least two loops.
* graphite-interchange.c (lst_interchange_select_outer): Return an int.
(scop_do_interchange): Same.
* graphite-poly.h (scop_do_interchange): Update declaration.
(scop_do_strip_mine): Same.
* gcc.dg/graphite/block-pr47654.c: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@175861 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/graphite-blocking.c')
-rw-r--r-- | gcc/graphite-blocking.c | 59 |
1 files changed, 26 insertions, 33 deletions
diff --git a/gcc/graphite-blocking.c b/gcc/graphite-blocking.c index bcd077a8310..967de9d9462 100644 --- a/gcc/graphite-blocking.c +++ b/gcc/graphite-blocking.c @@ -89,7 +89,7 @@ along with GCC; see the file COPYING3. If not see # } */ -static bool +static void pbb_strip_mine_time_depth (poly_bb_p pbb, int time_depth, int stride) { ppl_dimension_type iter, dim, strip; @@ -151,8 +151,6 @@ pbb_strip_mine_time_depth (poly_bb_p pbb, int time_depth, int stride) ppl_Polyhedron_add_constraint (res, new_cstr); ppl_delete_Constraint (new_cstr); } - - return true; } /* Returns true when strip mining with STRIDE of the loop LST is @@ -177,10 +175,10 @@ lst_strip_mine_profitable_p (lst_p lst, int stride) return res; } -/* Strip-mines all the loops of LST with STRIDE. Return true if it - did strip-mined some loops. */ +/* Strip-mines all the loops of LST with STRIDE. Return the number of + loops strip-mined. */ -static bool +static int lst_do_strip_mine_loop (lst_p lst, int depth, int stride) { int i; @@ -188,26 +186,26 @@ lst_do_strip_mine_loop (lst_p lst, int depth, int stride) poly_bb_p pbb; if (!lst) - return false; + return 0; if (LST_LOOP_P (lst)) { - bool res = false; + int res = 0; FOR_EACH_VEC_ELT (lst_p, LST_SEQ (lst), i, l) - res |= lst_do_strip_mine_loop (l, depth, stride); + res += lst_do_strip_mine_loop (l, depth, stride); return res; } pbb = LST_PBB (lst); - return pbb_strip_mine_time_depth (pbb, psct_dynamic_dim (pbb, depth), - stride); + pbb_strip_mine_time_depth (pbb, psct_dynamic_dim (pbb, depth), stride); + return 1; } /* Strip-mines all the loops of LST with STRIDE. When STRIDE is zero, - read the stride from the PARAM_LOOP_BLOCK_TILE_SIZE. Return true - if it did strip-mined some loops. + read the stride from the PARAM_LOOP_BLOCK_TILE_SIZE. Return the + number of strip-mined loops. Strip mining transforms a loop @@ -221,12 +219,12 @@ lst_do_strip_mine_loop (lst_p lst, int depth, int stride) | S (i = k + j); */ -static bool +static int lst_do_strip_mine (lst_p lst, int stride) { int i; lst_p l; - bool res = false; + int res = 0; int depth; if (!stride) @@ -237,23 +235,23 @@ lst_do_strip_mine (lst_p lst, int stride) return false; FOR_EACH_VEC_ELT (lst_p, LST_SEQ (lst), i, l) - res |= lst_do_strip_mine (l, stride); + res += lst_do_strip_mine (l, stride); depth = lst_depth (lst); if (depth >= 0 && lst_strip_mine_profitable_p (lst, stride)) { - res |= lst_do_strip_mine_loop (lst, lst_depth (lst), stride); + res += lst_do_strip_mine_loop (lst, lst_depth (lst), stride); lst_add_loop_under_loop (lst); } return res; } -/* Strip mines all the loops in SCOP. Returns true when some loops - have been strip-mined. */ +/* Strip mines all the loops in SCOP. Returns the number of + strip-mined loops. */ -bool +int scop_do_strip_mine (scop_p scop, int stride) { return lst_do_strip_mine (SCOP_TRANSFORMED_SCHEDULE (scop), stride); @@ -265,27 +263,22 @@ scop_do_strip_mine (scop_p scop, int stride) bool scop_do_block (scop_p scop) { - bool strip_mined = false; - bool interchanged = false; - store_scattering (scop); - strip_mined = lst_do_strip_mine (SCOP_TRANSFORMED_SCHEDULE (scop), 0); - interchanged = scop_do_interchange (scop); - - /* If we don't interchange loops, the strip mine alone will not be - profitable, and the transform is not a loop blocking: so revert - the transform. */ - if (!interchanged) + /* If we don't strip mine at least two loops, or not interchange + loops, the strip mine alone will not be profitable, and the + transform is not a loop blocking: so revert the transform. */ + if (lst_do_strip_mine (SCOP_TRANSFORMED_SCHEDULE (scop), 0) < 2 + || scop_do_interchange (scop) == 0) { restore_scattering (scop); return false; } - else if (strip_mined && interchanged - && dump_file && (dump_flags & TDF_DETAILS)) + + if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "SCoP will be loop blocked.\n"); - return strip_mined || interchanged; + return true; } #endif |