diff options
author | Richard Biener <rguenther@suse.de> | 2023-09-13 11:04:31 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2023-09-13 13:40:10 +0200 |
commit | 04238615bba435f0b0ca7b263ad2c6bdb596e865 (patch) | |
tree | 8b5310819a5c030e4d2923d7dc79e49d4aa8cafd /gcc/tree-vect-slp.cc | |
parent | c0a70df6403397a69204cba1df82114a9ddf7076 (diff) | |
download | gcc-04238615bba435f0b0ca7b263ad2c6bdb596e865.zip gcc-04238615bba435f0b0ca7b263ad2c6bdb596e865.tar.gz gcc-04238615bba435f0b0ca7b263ad2c6bdb596e865.tar.bz2 |
tree-optimization/111387 - BB SLP and irreducible regions
When we split an irreducible region for BB vectorization analysis
the defensive handling of external backedge defs in
vect_get_and_check_slp_defs doesn't work since that relies on
dominance info to identify a backedge. The testcase also shows
we are iterating over the function in a sub-optimal way which is
why we split the irreducible region in the first place. The fix
is to mark backedges and use EDGE_DFS_BACK to identify them and
to use the region RPO compute which can produce a RPO order keeping
cycles in a better order (and as side effect marks backedges).
PR tree-optimization/111387
* tree-vect-slp.cc (vect_get_and_check_slp_defs): Check
EDGE_DFS_BACK when doing BB vectorization.
(vect_slp_function): Use rev_post_order_and_mark_dfs_back_seme
to compute RPO and mark backedges.
* gcc.dg/torture/pr111387.c: New testcase.
Diffstat (limited to 'gcc/tree-vect-slp.cc')
-rw-r--r-- | gcc/tree-vect-slp.cc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index 0cf6e02..a3e54eb 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -628,9 +628,13 @@ vect_get_and_check_slp_defs (vec_info *vinfo, unsigned char swap, { oprnd = gimple_arg (stmt_info->stmt, opno); if (gphi *stmt = dyn_cast <gphi *> (stmt_info->stmt)) - backedge = dominated_by_p (CDI_DOMINATORS, - gimple_phi_arg_edge (stmt, opno)->src, - gimple_bb (stmt_info->stmt)); + { + edge e = gimple_phi_arg_edge (stmt, opno); + backedge = (is_a <bb_vec_info> (vinfo) + ? e->flags & EDGE_DFS_BACK + : dominated_by_p (CDI_DOMINATORS, e->src, + gimple_bb (stmt_info->stmt))); + } } if (TREE_CODE (oprnd) == VIEW_CONVERT_EXPR) oprnd = TREE_OPERAND (oprnd, 0); @@ -7771,7 +7775,11 @@ vect_slp_function (function *fun) { bool r = false; int *rpo = XNEWVEC (int, n_basic_blocks_for_fn (fun)); - unsigned n = pre_and_rev_post_order_compute_fn (fun, NULL, rpo, false); + auto_bitmap exit_bbs; + bitmap_set_bit (exit_bbs, EXIT_BLOCK); + edge entry = single_succ_edge (ENTRY_BLOCK_PTR_FOR_FN (fun)); + unsigned n = rev_post_order_and_mark_dfs_back_seme (fun, entry, exit_bbs, + true, rpo, NULL); /* For the moment split the function into pieces to avoid making the iteration on the vector mode moot. Split at points we know |