diff options
author | Richard Biener <rguenther@suse.de> | 2017-09-22 13:16:21 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2017-09-22 13:16:21 +0000 |
commit | 4d6e2f33a437fc6ead8218bf5f0e2cdb3e834d9e (patch) | |
tree | bd7aa309b1e9ebd76aaef48e163ddf24e3f686ba /gcc/graphite.c | |
parent | 2402ffb6711e01619f6fff7dc6f55be650ef2e23 (diff) | |
download | gcc-4d6e2f33a437fc6ead8218bf5f0e2cdb3e834d9e.zip gcc-4d6e2f33a437fc6ead8218bf5f0e2cdb3e834d9e.tar.gz gcc-4d6e2f33a437fc6ead8218bf5f0e2cdb3e834d9e.tar.bz2 |
graphite-isl-ast-to-gimple.c (graphite_verify): Inline into single caller.
2017-09-22 Richard Biener <rguenther@suse.de>
* graphite-isl-ast-to-gimple.c (graphite_verify): Inline into
single caller.
(graphite_regenerate_ast_isl): Do not reset SCEV. Move debug
print of no dependency loops ...
* graphite.c (graphite_transform_loops): ... here.
(canonicalize_loop_closed_ssa_form): Work from inner to outer
loops.
(same_close_phi_node, remove_duplicate_close_phi,
make_close_phi_nodes_unique, defined_in_loop_p): Fold into ...
(canonicalize_loop_closed_ssa): ... here and simplify.
* graphite-optimize-isl.c: Include tree-vectorizer.h.
(optimize_isl): Use dump_printf_loc to tell when we stopped
optimizing because of an ISL timeout.
* gcc.dg/graphite/scop-24.c: New testcase.
From-SVN: r253094
Diffstat (limited to 'gcc/graphite.c')
-rw-r--r-- | gcc/graphite.c | 127 |
1 files changed, 42 insertions, 85 deletions
diff --git a/gcc/graphite.c b/gcc/graphite.c index bce3240..a5a31c2 100644 --- a/gcc/graphite.c +++ b/gcc/graphite.c @@ -293,86 +293,6 @@ free_scops (vec<scop_p> scops) scops.release (); } -/* Returns true when P1 and P2 are close phis with the same - argument. */ - -static inline bool -same_close_phi_node (gphi *p1, gphi *p2) -{ - return (types_compatible_p (TREE_TYPE (gimple_phi_result (p1)), - TREE_TYPE (gimple_phi_result (p2))) - && operand_equal_p (gimple_phi_arg_def (p1, 0), - gimple_phi_arg_def (p2, 0), 0)); -} - -static void make_close_phi_nodes_unique (basic_block bb); - -/* Remove the close phi node at GSI and replace its rhs with the rhs - of PHI. */ - -static void -remove_duplicate_close_phi (gphi *phi, gphi_iterator *gsi) -{ - gimple *use_stmt; - use_operand_p use_p; - imm_use_iterator imm_iter; - tree res = gimple_phi_result (phi); - tree def = gimple_phi_result (gsi->phi ()); - - gcc_assert (same_close_phi_node (phi, gsi->phi ())); - - FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, def) - { - FOR_EACH_IMM_USE_ON_STMT (use_p, imm_iter) - SET_USE (use_p, res); - - update_stmt (use_stmt); - - /* It is possible that we just created a duplicate close-phi - for an already-processed containing loop. Check for this - case and clean it up. */ - if (gimple_code (use_stmt) == GIMPLE_PHI - && gimple_phi_num_args (use_stmt) == 1) - make_close_phi_nodes_unique (gimple_bb (use_stmt)); - } - - remove_phi_node (gsi, true); -} - -/* Removes all the close phi duplicates from BB. */ - -static void -make_close_phi_nodes_unique (basic_block bb) -{ - gphi_iterator psi; - - for (psi = gsi_start_phis (bb); !gsi_end_p (psi); gsi_next (&psi)) - { - gphi_iterator gsi = psi; - gphi *phi = psi.phi (); - - /* At this point, PHI should be a close phi in normal form. */ - gcc_assert (gimple_phi_num_args (phi) == 1); - - /* Iterate over the next phis and remove duplicates. */ - gsi_next (&gsi); - while (!gsi_end_p (gsi)) - if (same_close_phi_node (phi, gsi.phi ())) - remove_duplicate_close_phi (phi, &gsi); - else - gsi_next (&gsi); - } -} - -/* Return true when NAME is defined in LOOP. */ - -static bool -defined_in_loop_p (tree name, loop_p loop) -{ - gcc_assert (TREE_CODE (name) == SSA_NAME); - return loop == loop_containing_stmt (SSA_NAME_DEF_STMT (name)); -} - /* Transforms LOOP to the canonical loop closed SSA form. */ static void @@ -380,20 +300,22 @@ canonicalize_loop_closed_ssa (loop_p loop) { edge e = single_exit (loop); basic_block bb; + gphi_iterator psi; if (!e || (e->flags & EDGE_COMPLEX)) return; bb = e->dest; + /* Make the loop-close PHI node BB contain only PHIs and have a + single predecessor. */ if (single_pred_p (bb)) { e = split_block_after_labels (bb); - make_close_phi_nodes_unique (e->src); + bb = e->src; } else { - gphi_iterator psi; basic_block close = split_edge (e); e = single_succ_edge (close); for (psi = gsi_start_phis (bb); !gsi_end_p (psi); gsi_next (&psi)) @@ -404,7 +326,7 @@ canonicalize_loop_closed_ssa (loop_p loop) /* Only add close phi nodes for SSA_NAMEs defined in LOOP. */ if (TREE_CODE (arg) != SSA_NAME - || !defined_in_loop_p (arg, loop)) + || loop_containing_stmt (SSA_NAME_DEF_STMT (arg)) != loop) continue; tree res = copy_ssa_name (arg); @@ -413,8 +335,30 @@ canonicalize_loop_closed_ssa (loop_p loop) UNKNOWN_LOCATION); SET_USE (use_p, res); } + bb = close; + } + + /* Eliminate duplicates. This relies on processing loops from + innermost to outer. */ + for (psi = gsi_start_phis (bb); !gsi_end_p (psi); gsi_next (&psi)) + { + gphi_iterator gsi = psi; + gphi *phi = psi.phi (); + + /* At this point, PHI should be a close phi in normal form. */ + gcc_assert (gimple_phi_num_args (phi) == 1); - make_close_phi_nodes_unique (close); + /* Iterate over the next phis and remove duplicates. */ + gsi_next (&gsi); + while (!gsi_end_p (gsi)) + if (gimple_phi_arg_def (phi, 0) == gimple_phi_arg_def (gsi.phi (), 0)) + { + replace_uses_by (gimple_phi_result (gsi.phi ()), + gimple_phi_result (phi)); + remove_phi_node (&gsi, true); + } + else + gsi_next (&gsi); } } @@ -443,7 +387,7 @@ static void canonicalize_loop_closed_ssa_form (void) { loop_p loop; - FOR_EACH_LOOP (loop, 0) + FOR_EACH_LOOP (loop, LI_FROM_INNERMOST) canonicalize_loop_closed_ssa (loop); checking_verify_loop_closed_ssa (true); @@ -509,6 +453,19 @@ graphite_transform_loops (void) "loop nest optimized\n"); } + if (dump_file && (dump_flags & TDF_DETAILS)) + { + loop_p loop; + int num_no_dependency = 0; + + FOR_EACH_LOOP (loop, 0) + if (loop->can_be_parallel) + num_no_dependency++; + + fprintf (dump_file, "%d loops carried no dependency.\n", + num_no_dependency); + } + free_scops (scops); graphite_finalize (need_cfg_cleanup_p); the_isl_ctx = NULL; |