X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=gcc%2Fgraphite-blocking.c;h=769cda45bb47c040f17a8baaac978c5d58dbd638;hb=7ef5673218d8691ed5ae75852b41920ee2f7bab2;hp=e44ad8a921cceee6919186cd41ea0474ae51752a;hpb=43217ce91110f35e448c42647e969093efc4e8e9;p=pf3gnuchains%2Fgcc-fork.git diff --git a/gcc/graphite-blocking.c b/gcc/graphite-blocking.c index e44ad8a921c..769cda45bb4 100644 --- a/gcc/graphite-blocking.c +++ b/gcc/graphite-blocking.c @@ -174,23 +174,23 @@ pbb_strip_mine_time_depth (poly_bb_p pbb, int time_depth, int stride) } /* Returns true when strip mining with STRIDE of the loop around PBB - at scattering time TIME_DEPTH is profitable. */ + at DEPTH is profitable. */ static bool pbb_strip_mine_profitable_p (poly_bb_p pbb, - graphite_dim_t time_depth, + graphite_dim_t depth, int stride) { - Value niter, strip_stride; + mpz_t niter, strip_stride; bool res; - value_init (strip_stride); - value_init (niter); - value_set_si (strip_stride, stride); - pbb_number_of_iterations_at_time (pbb, time_depth, niter); - res = value_gt (niter, strip_stride); - value_clear (strip_stride); - value_clear (niter); + mpz_init (strip_stride); + mpz_init (niter); + mpz_set_si (strip_stride, stride); + pbb_number_of_iterations_at_time (pbb, psct_dynamic_dim (pbb, depth), niter); + res = (mpz_cmp (niter, strip_stride) > 0); + mpz_clear (strip_stride); + mpz_clear (niter); return res; } @@ -234,6 +234,7 @@ lst_do_strip_mine (lst_p lst) lst_p l; bool res = false; int stride = PARAM_VALUE (PARAM_LOOP_BLOCK_TILE_SIZE); + int depth; if (!lst || !LST_LOOP_P (lst)) @@ -242,9 +243,10 @@ lst_do_strip_mine (lst_p lst) for (i = 0; VEC_iterate (lst_p, LST_SEQ (lst), i, l); i++) res |= lst_do_strip_mine (l); - if (lst_depth (lst) >= 0 + depth = lst_depth (lst); + if (depth >= 0 && pbb_strip_mine_profitable_p (LST_PBB (lst_find_first_pbb (lst)), - lst_depth (lst), stride)) + depth, stride)) { res |= lst_do_strip_mine_loop (lst, lst_depth (lst)); lst_add_loop_under_loop (lst); @@ -253,7 +255,6 @@ lst_do_strip_mine (lst_p lst) return res; } - /* Strip mines all the loops in SCOP. Nothing profitable in all this: this is just a driver function. */ @@ -278,4 +279,33 @@ scop_do_strip_mine (scop_p scop) return transform_done; } +/* Loop blocks all the loops in SCOP. Returns true when we manage to + block some loops. */ + +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)); + interchanged = scop_do_interchange (scop); + + /* If we don't interchange loops, then the strip mine is not + profitable, and the transform is not a loop blocking. */ + if (!interchanged + || !graphite_legal_transform (scop)) + { + restore_scattering (scop); + return false; + } + else if (strip_mined && interchanged + && dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, "SCoP will be loop blocked.\n"); + + return strip_mined || interchanged; +} + #endif