The following (on top of what I sent yesterday and on top of your four vectype
patches) "passed" regtesting just now.
I do see regressions for zve32x-3.c et al. Those might be related to the
recently fixed tests regarding partial vectorization with vector(1) types
but I haven't checked further for now.
These tests don't use the LMUL heuristic so the failures can't be due to it.
I'll see if I can have a look tomorrow.
Regards
Robin
commit ac4c46ee66380fc81b4f4dc0138956e1f2c519c7
Author: Robin Dapp <rd...@ventanamicro.com>
Date: Wed Jul 23 15:31:38 2025 +0200
slp type map stmt_vinfo_vectype
diff --git a/gcc/config/riscv/riscv-vector-costs.cc
b/gcc/config/riscv/riscv-vector-costs.cc
index df924fafd8e..57932d22c14 100644
--- a/gcc/config/riscv/riscv-vector-costs.cc
+++ b/gcc/config/riscv/riscv-vector-costs.cc
@@ -602,7 +602,7 @@ get_store_value (gimple *stmt)
/* Return true if additional vector vars needed. */
bool
costs::need_additional_vector_vars_p (stmt_vec_info stmt_info,
- slp_tree node ATTRIBUTE_UNUSED)
+ slp_tree node)
{
enum stmt_vec_info_type type = STMT_VINFO_TYPE (stmt_info);
if (type == load_vec_info_type || type == store_vec_info_type)
@@ -611,7 +611,8 @@ costs::need_additional_vector_vars_p (stmt_vec_info
stmt_info,
&& STMT_VINFO_MEMORY_ACCESS_TYPE (stmt_info) == VMAT_GATHER_SCATTER)
return true;
- machine_mode mode = TYPE_MODE (STMT_VINFO_VECTYPE (stmt_info));
+ tree *vectype = slp_type_map.get (node);
+ machine_mode mode = TYPE_MODE (*vectype);
int lmul = riscv_get_v_regno_alignment (mode);
if (DR_GROUP_SIZE (stmt_info) * lmul > RVV_M8)
return true;
@@ -1257,6 +1258,9 @@ costs::add_stmt_cost (int count, vect_cost_for_stmt kind,
if (stmt_info && node)
vinfo_slp_map.put (stmt_info, node);
+ if (node)
+ slp_type_map.put (node, vectype);
+
/* Do one-time initialization based on the vinfo. */
loop_vec_info loop_vinfo = dyn_cast<loop_vec_info> (m_vinfo);
diff --git a/gcc/config/riscv/riscv-vector-costs.h
b/gcc/config/riscv/riscv-vector-costs.h
index b84ceb1d3cf..dd895c769d2 100644
--- a/gcc/config/riscv/riscv-vector-costs.h
+++ b/gcc/config/riscv/riscv-vector-costs.h
@@ -92,6 +92,7 @@ private:
hash_set <tree_pair_hash> memrefs;
hash_map <stmt_vec_info, slp_tree> vinfo_slp_map;
+ hash_map <slp_tree, tree> slp_type_map;
void analyze_loop_vinfo (loop_vec_info);
void record_lmul_spills (loop_vec_info loop_vinfo);