------- Comment #2 from nemokingdom at gmail dot com 2009-03-30 11:30 ------- I test with bootstrap enabled and success. Here is the patch:
Index: sese.h =================================================================== --- sese.h (revision 145190) +++ sese.h (working copy) @@ -341,54 +341,6 @@ CASE_LABEL_EXPR. */ VEC (gimple, heap) *conditions; VEC (gimple, heap) *condition_cases; - - /* LOOPS contains for every column in the graphite domain the corresponding - gimple loop. If there exists no corresponding gimple loop LOOPS contains - NULL. - - Example: - - Original code: - - for (i = 0; i <= 20; i++) - for (j = 5; j <= 10; j++) - A - - Original domain: - - | i >= 0 - | i <= 20 - | j >= 0 - | j <= 10 - - This is a two dimensional domain with "Loop i" represented in - dimension 0, and "Loop j" represented in dimension 1. Original - loops vector: - - | 0 1 - | Loop i Loop j - - After some changes (Exchange i and j, strip-mine i), the domain - is: - - | i >= 0 - | i <= 20 - | j >= 0 - | j <= 10 - | ii <= i - | ii + 1 >= i - | ii <= 2k - | ii >= 2k - - Iterator vector: - | 0 1 2 3 - | Loop j NULL Loop i NULL - - Means the original loop i is now on dimension 2 of the domain and - loop j in the original loop nest is now on dimension 0. - Dimensions 1 and 3 represent the newly created loops. */ - VEC (loop_p, heap) *loops; - VEC (data_reference_p, heap) *data_refs; htab_t cloog_iv_types; } *gimple_bb_p; @@ -397,10 +349,9 @@ #define GBB_DATA_REFS(GBB) GBB->data_refs #define GBB_CONDITIONS(GBB) GBB->conditions #define GBB_CONDITION_CASES(GBB) GBB->condition_cases -#define GBB_LOOPS(GBB) (GBB->loops) #define GBB_CLOOG_IV_TYPES(GBB) GBB->cloog_iv_types -/* Return the loop that contains the basic block GBB. */ +/* Return the innermost loop that contains the basic block GBB. */ static inline struct loop * gbb_loop (struct gimple_bb *gbb) @@ -412,24 +363,26 @@ If there is no corresponding gimple loop, we return NULL. */ static inline loop_p -gbb_loop_at_index (gimple_bb_p gbb, int index) +gbb_loop_at_index (gimple_bb_p gbb, sese region, int index) { - return VEC_index (loop_p, GBB_LOOPS (gbb), index); -} + loop_p loop = gbb_loop (gbb); + int depth = sese_loop_depth (region, loop); -/* Returns the index of LOOP in the loop nest around GBB. */ + while (--depth > index) + { + loop = loop_outer (loop); + } + gcc_assert (sese_contains_loop (region, loop)); + + return loop; +} + +/* Returns the index of LOOP in the region, 0 based index */ static inline int -gbb_loop_index (gimple_bb_p gbb, loop_p loop) +gbb_loop_index (sese region, loop_p loop) { - int i; - loop_p l; - - for (i = 0; VEC_iterate (loop_p, GBB_LOOPS (gbb), i, l); i++) - if (loop == l) - return i; - - gcc_unreachable(); + return sese_loop_depth (region, loop) - 1; } /* The number of common loops in REGION for GBB1 and GBB2. */ Index: graphite-clast-to-gimple.c =================================================================== --- graphite-clast-to-gimple.c (revision 145190) +++ graphite-clast-to-gimple.c (working copy) @@ -316,6 +316,7 @@ int index = 0; CloogStatement *cs = user_stmt->statement; poly_bb_p pbb = (poly_bb_p) cloog_statement_usr (cs); + sese region = SCOP_REGION (PBB_SCOP (pbb)); for (t = user_stmt->substitutions; t; t = t->next) { @@ -327,8 +328,8 @@ if (expr->type == expr_term && !term->var) { - loop_p loop = gbb_loop_at_index (PBB_BLACK_BOX (pbb), index); - tree oldiv = oldiv_for_loop (SCOP_REGION (PBB_SCOP (pbb)), loop); + loop_p loop = gbb_loop_at_index (PBB_BLACK_BOX (pbb), region, index); + tree oldiv = oldiv_for_loop (region, loop); tree type = oldiv ? TREE_TYPE (oldiv) : integer_type_node; tree value = gmp_cst_to_tree (type, term->val); loop_iv_stack_insert_constant (stack, index, value); @@ -507,7 +508,8 @@ free (*slot); new_name = loop_iv_stack_get_iv - (ivstack, gbb_loop_index (PBB_BLACK_BOX (pbb), iv->loop)); + (ivstack, gbb_loop_index (region, iv->loop)); + *slot = new_rename_map_elt (old_name, new_name); } } @@ -685,6 +687,7 @@ { gimple_bb_p gbb = PBB_BLACK_BOX (pbb); struct clast_stmt *t; + sese region = SCOP_REGION (PBB_SCOP (pbb)); int index = 0; for (t = user_stmt->substitutions; t; t = t->next, index++) @@ -703,8 +706,8 @@ if (!*slot) { - loop_p loop = gbb_loop_at_index (PBB_BLACK_BOX (pbb), index); - tree oldiv = oldiv_for_loop (SCOP_REGION (PBB_SCOP (pbb)), loop); + loop_p loop = gbb_loop_at_index (PBB_BLACK_BOX (pbb), region, index); + tree oldiv = oldiv_for_loop (region, loop); tree type = oldiv ? TREE_TYPE (oldiv) : integer_type_node; *slot = new_ivtype_map_elt (tmp.cloog_iv, type); } Index: graphite-sese-to-poly.c =================================================================== --- graphite-sese-to-poly.c (revision 145190) +++ graphite-sese-to-poly.c (working copy) @@ -115,7 +115,6 @@ GBB_CONDITIONS (gbb) = NULL; GBB_CONDITION_CASES (gbb) = NULL; GBB_CLOOG_IV_TYPES (gbb) = NULL; - GBB_LOOPS (gbb) = NULL; return gbb; } @@ -133,7 +132,6 @@ free_data_refs (GBB_DATA_REFS (gbb)); */ - VEC_free (loop_p, heap, GBB_LOOPS (gbb)); VEC_free (gimple, heap, GBB_CONDITIONS (gbb)); VEC_free (gimple, heap, GBB_CONDITION_CASES (gbb)); GBB_BB (gbb)->aux = 0; @@ -451,36 +449,6 @@ ppl_delete_Linear_Expression (static_schedule); } -/* Build the LOOPS vector for all bbs in SCOP. */ - -static void -build_bb_loops (scop_p scop) -{ - poly_bb_p pbb; - int i; - - for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb); i++) - { - loop_p loop; - int depth; - gimple_bb_p gbb = PBB_BLACK_BOX (pbb); - - loop = GBB_BB (gbb)->loop_father; - depth = sese_loop_depth (SCOP_REGION (scop), loop); - - GBB_LOOPS (gbb) = VEC_alloc (loop_p, heap, 3); - VEC_safe_grow_cleared (loop_p, heap, GBB_LOOPS (gbb), depth); - - - while (sese_contains_loop (SCOP_REGION(scop), loop)) - { - VEC_replace (loop_p, GBB_LOOPS (gbb), depth - 1, loop); - loop = loop_outer (loop); - depth--; - } - } -} - /* Add the value K to the dimension D of the linear expression EXPR. */ static void @@ -1266,7 +1234,6 @@ if (scop_contains_non_iv_scalar_phi_nodes (scop)) return false; - build_bb_loops (scop); build_sese_conditions (region); find_scop_parameters (scop); scop_set_nb_params (scop, sese_nb_params (region)); (In reply to comment #0) > We create an LOOPS vector for every gimple_bb in a SCoP. This is not > necessary. > > It is just used for the functions > gbb_loop_index and gbb_loop_at_index > > As the order of the LOOPS vector never changes (all transformations are made > using the scattering functions) it can be replaced in > gbb_loop_index with a simple call to sese_loop_depth > gbb_loop_at_index can be implemented in the style of sese_loop_depth. > -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39568