From acba581956b8eb36ffcb56166286c148d544eac2 Mon Sep 17 00:00:00 2001 From: spop Date: Wed, 25 Nov 2009 05:31:36 +0000 Subject: [PATCH] 2009-11-18 Sebastian Pop * graphite-interchange.c (memory_strides_in_loop_depth): New. (pbb_interchange_profitable_p): Call memory_strides_in_loop_depth. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154639 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog.graphite | 5 +++++ gcc/graphite-interchange.c | 52 ++++++++++++++++++++++++++-------------------- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite index 8ae2d55c71a..567d0e97cc2 100644 --- a/gcc/ChangeLog.graphite +++ b/gcc/ChangeLog.graphite @@ -1,5 +1,10 @@ 2009-11-18 Sebastian Pop + * graphite-interchange.c (memory_strides_in_loop_depth): New. + (pbb_interchange_profitable_p): Call memory_strides_in_loop_depth. + +2009-11-18 Sebastian Pop + * graphite-blocking.c (scop_do_block): New. * graphite-poly.c (apply_poly_transforms): Call scop_do_block. * graphite-poly.h (scop_do_block): Declared. diff --git a/gcc/graphite-interchange.c b/gcc/graphite-interchange.c index 42a0b1dac7f..280a14e6d45 100644 --- a/gcc/graphite-interchange.c +++ b/gcc/graphite-interchange.c @@ -193,7 +193,7 @@ build_partial_difference (ppl_Pointset_Powerset_C_Polyhedron_t *p, /* Set STRIDE to the stride of PDR in memory by advancing by one in - time dimension DEPTH. */ + the loop at DEPTH. */ static void memory_stride_in_loop (Value stride, graphite_dim_t depth, poly_dr_p pdr) @@ -329,6 +329,32 @@ memory_stride_in_loop (Value stride, graphite_dim_t depth, poly_dr_p pdr) ppl_delete_Linear_Expression (le); } +/* Sets STRIDES to the sum of all the strides of the data references accessed */ + +static void +memory_strides_in_loop_depth (poly_bb_p pbb, graphite_dim_t depth, Value strides) +{ + int i; + poly_dr_p pdr; + Value s, n; + + value_set_si (strides, 0); + value_init (s); + value_init (n); + + for (i = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb), i, pdr); i++) + { + value_set_si (n, PDR_NB_REFS (pdr)); + + memory_stride_in_loop (s, depth, pdr); + value_multiply (s, s, n); + value_addto (strides, strides, s); + } + + value_clear (s); + value_clear (n); +} + /* Returns true when it is profitable to interchange time dimensions DEPTH1 and DEPTH2 with DEPTH1 < DEPTH2 for PBB. @@ -414,39 +440,21 @@ static bool pbb_interchange_profitable_p (graphite_dim_t depth1, graphite_dim_t depth2, poly_bb_p pbb) { - int i; - poly_dr_p pdr; - Value d1, d2, s, n; + Value d1, d2; bool res; gcc_assert (depth1 < depth2); value_init (d1); - value_set_si (d1, 0); value_init (d2); - value_set_si (d2, 0); - value_init (s); - value_init (n); - for (i = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb), i, pdr); i++) - { - value_set_si (n, PDR_NB_REFS (pdr)); - - memory_stride_in_loop (s, depth1, pdr); - value_multiply (s, s, n); - value_addto (d1, d1, s); - - memory_stride_in_loop (s, depth2, pdr); - value_multiply (s, s, n); - value_addto (d2, d2, s); - } + memory_strides_in_loop_depth (pbb, depth1, d1); + memory_strides_in_loop_depth (pbb, depth2, d2); res = value_lt (d1, d2); value_clear (d1); value_clear (d2); - value_clear (s); - value_clear (n); return res; } -- 2.11.0