On Wed, 04 Sep 2024 04:10:52 PDT (-0700), rguent...@suse.de wrote:
The following adds SLP discovery for roots that are only live but
otherwise unused. These are usually inductions. This allows a
few more testcases to be handled fully with SLP, for example
gcc.dg/vect/no-scevccp-pr86725-1.c
Bootstrap and regtest running on x86_64-unknown-linux-gnu.
* tree-vect-slp.cc (vect_analyze_slp): Analyze SLP for live
but otherwise unused defs.
---
gcc/tree-vect-slp.cc | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
Are you putting the "RISC-V" in there just to kick the CI into running
it? If so you can also just CC <patchworks...@rivosinc.com> (or trip
anything that matches the filter at [1]). No big deal on my end, just
worried non-RISC-V people are going to see the tag and think this is
RISC-V-only and thus ignore it.
If you're looking for a RISC-V reviewer, I don't really know this stuff
well enough to say much here. Robin would probably be the best bet...
[1]:
https://github.com/patrick-rivos/riscv-gnu-toolchain/blob/1496f76a9ad4081c0afdde8f7f8ffb22573a1789/scripts/create_patches_files.py#L89
diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index 41bc92b138a..91d6927016d 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -4704,6 +4704,36 @@ vect_analyze_slp (vec_info *vinfo, unsigned
max_tree_size)
saved_stmts.release ();
}
}
+
+ /* Make sure to vectorize only-live stmts, usually inductions. */
+ for (edge e : get_loop_exit_edges (LOOP_VINFO_LOOP (loop_vinfo)))
+ for (auto gsi = gsi_start_phis (e->dest); !gsi_end_p (gsi);
+ gsi_next (&gsi))
+ {
+ gphi *lc_phi = *gsi;
+ tree def = gimple_phi_arg_def_from_edge (lc_phi, e);
+ stmt_vec_info stmt_info;
+ if (TREE_CODE (def) == SSA_NAME
+ && !virtual_operand_p (def)
+ && (stmt_info = loop_vinfo->lookup_def (def))
+ && STMT_VINFO_RELEVANT (stmt_info) == vect_used_only_live
+ && STMT_VINFO_LIVE_P (stmt_info)
+ && (STMT_VINFO_DEF_TYPE (stmt_info) == vect_induction_def
+ || (STMT_VINFO_DEF_TYPE (stmt_info) == vect_internal_def
+ && STMT_VINFO_REDUC_IDX (stmt_info) == -1)))
+ {
+ vec<stmt_vec_info> stmts;
+ vec<stmt_vec_info> roots = vNULL;
+ vec<tree> remain = vNULL;
+ stmts.create (1);
+ stmts.quick_push (vect_stmt_to_vectorize (stmt_info));
+ vect_build_slp_instance (vinfo,
+ slp_inst_kind_reduc_group,
+ stmts, roots, remain,
+ max_tree_size, &limit,
+ bst_map, NULL);
+ }
+ }
}
hash_set<slp_tree> visited_patterns;