From caf5b4dfca050e8e93b1ee15705ab9c759854f40 Mon Sep 17 00:00:00 2001 From: Aditya Kumar Date: Wed, 21 Oct 2015 18:53:26 +0000 Subject: [PATCH] Refactor graphite-sese-to-poly, sese.h, graphite-poly.h Now that scop contains a list of all the basic blocks inside, it makes sense to iterate over only those basic blocks in graphite-sese-to-poly.c:rewrite_reductions_out_of_ssa,rewrite_cross_bb_scalar_deps_out_of_ssa Passes regtest and bootstrap. gcc/ChangeLog: 2015-10-20 Aditya Kumar * graphite-poly.h (struct dr_info): Added invalid_alias_set number. (operator=): Removed. (dr_info): Make alias_set number the last argument with default value of invalid_alias_set. * graphite-sese-to-poly.c (build_scop_drs): Update constructor of dr_info. (rewrite_reductions_out_of_ssa): Iterate only through the basic blocks which are inside region. (rewrite_cross_bb_scalar_deps_out_of_ssa): Same. * sese.h (struct sese_l): Removed assignment operator. (split_region_for_bb): Removed dead code. From-SVN: r229136 --- gcc/ChangeLog | 11 ++++++++ gcc/graphite-poly.h | 26 ++++++++----------- gcc/graphite-sese-to-poly.c | 50 ++++++++++++++++++------------------- gcc/sese.h | 37 --------------------------- 4 files changed, 45 insertions(+), 79 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cfd6a13e9e7..8b4735d4626 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2015-10-21 Aditya Kumar + + * graphite-poly.h (struct dr_info): Added invalid_alias_set number. + (operator=): Removed. + (dr_info): Make alias_set number the last argument with default value of invalid_alias_set. + * graphite-sese-to-poly.c (build_scop_drs): Update constructor of dr_info. + (rewrite_reductions_out_of_ssa): Iterate only through the basic blocks which are inside region. + (rewrite_cross_bb_scalar_deps_out_of_ssa): Same. + * sese.h (struct sese_l): Removed assignment operator. + (split_region_for_bb): Removed dead code. + 2015-10-21 Aditya Kumar * graphite-poly.h (struct dr_info): Removed conversion constructor. diff --git a/gcc/graphite-poly.h b/gcc/graphite-poly.h index 721e9142088..5298f8547f9 100644 --- a/gcc/graphite-poly.h +++ b/gcc/graphite-poly.h @@ -373,29 +373,23 @@ pbb_set_black_box (poly_bb_p pbb, gimple_poly_bb_p black_box) struct dr_info { + enum { + invalid_alias_set = -1 + }; /* The data reference. */ data_reference_p dr; - /* ALIAS_SET is the SCC number assigned by a graph_dfs of the alias graph. -1 - is an invalid alias set. */ - int alias_set; - /* The polyhedral BB containing this DR. */ poly_bb_p pbb; + /* ALIAS_SET is the SCC number assigned by a graph_dfs of the alias graph. + -1 is an invalid alias set. */ + int alias_set; + /* Construct a DR_INFO from a data reference DR, an ALIAS_SET, and a PBB. */ - dr_info (data_reference_p dr, int alias_set, poly_bb_p pbb) - : dr (dr), alias_set (alias_set), pbb (pbb) {} - - /* Assignment operator, to be able to iterate over a vec of these objects. */ - const dr_info & - operator= (const dr_info &p) - { - dr = p.dr; - alias_set = p.alias_set; - pbb = p.pbb; - return *this; - } + dr_info (data_reference_p dr, poly_bb_p pbb, + int alias_set = invalid_alias_set) + : dr (dr), pbb (pbb), alias_set (alias_set) {} }; /* A SCOP is a Static Control Part of the program, simple enough to be diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c index d75e6a2ca30..d1eae9036ec 100644 --- a/gcc/graphite-sese-to-poly.c +++ b/gcc/graphite-sese-to-poly.c @@ -1151,7 +1151,7 @@ build_scop_drs (scop_p scop) FOR_EACH_VEC_ELT (scop->pbbs, i, pbb) if (pbb) FOR_EACH_VEC_ELT (GBB_DATA_REFS (PBB_BLACK_BOX (pbb)), j, dr) - scop->drs.safe_push (dr_info (dr, -1, pbb)); + scop->drs.safe_push (dr_info (dr, pbb)); build_alias_set (scop); @@ -1497,31 +1497,29 @@ rewrite_degenerate_phi (gphi_iterator *psi) static void rewrite_reductions_out_of_ssa (scop_p scop) { + int i; basic_block bb; - sese_l region = scop->scop_info->region; - - FOR_EACH_BB_FN (bb, cfun) - if (bb_in_sese_p (bb, region)) - for (gphi_iterator psi = gsi_start_phis (bb); !gsi_end_p (psi);) - { - gphi *phi = psi.phi (); + FOR_EACH_VEC_ELT (scop->scop_info->bbs, i, bb) + for (gphi_iterator psi = gsi_start_phis (bb); !gsi_end_p (psi);) + { + gphi *phi = psi.phi (); - if (virtual_operand_p (gimple_phi_result (phi))) - { - gsi_next (&psi); - continue; - } + if (virtual_operand_p (gimple_phi_result (phi))) + { + gsi_next (&psi); + continue; + } - if (gimple_phi_num_args (phi) > 1 - && degenerate_phi_result (phi)) - rewrite_degenerate_phi (&psi); + if (gimple_phi_num_args (phi) > 1 + && degenerate_phi_result (phi)) + rewrite_degenerate_phi (&psi); - else if (scalar_close_phi_node_p (phi)) - rewrite_close_phi_out_of_ssa (scop, &psi); + else if (scalar_close_phi_node_p (phi)) + rewrite_close_phi_out_of_ssa (scop, &psi); - else if (reduction_phi_p (region, &psi)) - rewrite_phi_out_of_ssa (scop, &psi); - } + else if (reduction_phi_p (scop->scop_info->region, &psi)) + rewrite_phi_out_of_ssa (scop, &psi); + } update_ssa (TODO_update_ssa); #ifdef ENABLE_CHECKING @@ -1684,7 +1682,6 @@ rewrite_cross_bb_scalar_deps (scop_p scop, gimple_stmt_iterator *gsi) static void rewrite_cross_bb_scalar_deps_out_of_ssa (scop_p scop) { - basic_block bb; gimple_stmt_iterator psi; sese_l region = scop->scop_info->region; bool changed = false; @@ -1692,10 +1689,11 @@ rewrite_cross_bb_scalar_deps_out_of_ssa (scop_p scop) /* Create an extra empty BB after the scop. */ split_edge (region.exit); - FOR_EACH_BB_FN (bb, cfun) - if (bb_in_sese_p (bb, region)) - for (psi = gsi_start_bb (bb); !gsi_end_p (psi); gsi_next (&psi)) - changed |= rewrite_cross_bb_scalar_deps (scop, &psi); + int i; + basic_block bb; + FOR_EACH_VEC_ELT (scop->scop_info->bbs, i, bb) + for (psi = gsi_start_bb (bb); !gsi_end_p (psi); gsi_next (&psi)) + changed |= rewrite_cross_bb_scalar_deps (scop, &psi); if (changed) { diff --git a/gcc/sese.h b/gcc/sese.h index f2dd55ee659..6b6b904495c 100644 --- a/gcc/sese.h +++ b/gcc/sese.h @@ -32,14 +32,6 @@ struct sese_l operator bool () const { return entry && exit; } - const sese_l & - operator= (const sese_l &s) - { - entry = s.entry; - exit = s.exit; - return *this; - } - edge entry; edge exit; }; @@ -205,35 +197,6 @@ sese_loop_depth (sese_l ®ion, loop_p loop) return depth; } -/* Splits BB to make a single entry single exit region. */ - -static inline sese_info_p -split_region_for_bb (basic_block bb) -{ - edge entry, exit; - - if (single_pred_p (bb)) - entry = single_pred_edge (bb); - else - { - entry = split_block_after_labels (bb); - bb = single_succ (bb); - } - - if (single_succ_p (bb)) - exit = single_succ_edge (bb); - else - { - gimple_stmt_iterator gsi = gsi_last_bb (bb); - gsi_prev (&gsi); - exit = split_block (bb, gsi_stmt (gsi)); - } - - return new_sese_info (entry, exit); -} - - - /* A single entry single exit specialized for conditions. */ typedef struct ifsese_s { -- 2.30.2