aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2024-12-03 14:37:21 +0100
committerRichard Biener <rguenth@gcc.gnu.org>2024-12-04 10:12:29 +0100
commit27b444a41a6afab8020183c4c5d3361e21635031 (patch)
tree4d404765111c5095d20a38fadd118b236997b747 /gcc
parentfb64a7b0e1d7488e6e3ae96af8d97fd2226b6d21 (diff)
downloadgcc-27b444a41a6afab8020183c4c5d3361e21635031.zip
gcc-27b444a41a6afab8020183c4c5d3361e21635031.tar.gz
gcc-27b444a41a6afab8020183c4c5d3361e21635031.tar.bz2
tree-optimization/116083 - SLP discovery slowness
One large constant factor of SLP discovery is figuring the vector type for each individual lane of each node. That should be redundant since the structual comparison of stmts should ensure they end up the same so the following computes them only once per node rather than for each lane. This cuts the compile-time of the testcase in half. PR tree-optimization/116083 * tree-vect-slp.cc (vect_build_slp_tree_1): Compute vector type and max_nunits only once. Remove check for matching vector type of each lane and replace it with matching check for LHS type.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/tree-vect-slp.cc57
1 files changed, 29 insertions, 28 deletions
diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index 425135a..9ad9510 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -1092,8 +1092,8 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
code_helper first_stmt_code = ERROR_MARK;
code_helper alt_stmt_code = ERROR_MARK;
code_helper first_cond_code = ERROR_MARK;
- tree lhs;
bool need_same_oprnds = false;
+ tree first_lhs = NULL_TREE;
tree first_op1 = NULL_TREE;
stmt_vec_info first_load = NULL, prev_first_load = NULL;
bool first_stmt_ldst_p = false;
@@ -1102,6 +1102,29 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
bool maybe_soft_fail = false;
tree soft_fail_nunits_vectype = NULL_TREE;
+ tree vectype, nunits_vectype;
+ if (!vect_get_vector_types_for_stmt (vinfo, first_stmt_info, &vectype,
+ &nunits_vectype, group_size))
+ {
+ /* Fatal mismatch. */
+ matches[0] = false;
+ return false;
+ }
+ /* Record nunits required but continue analysis, producing matches[]
+ as if nunits was not an issue. This allows splitting of groups
+ to happen. */
+ if (nunits_vectype
+ && !vect_record_max_nunits (vinfo, first_stmt_info, group_size,
+ nunits_vectype, max_nunits))
+ {
+ gcc_assert (is_a <bb_vec_info> (vinfo));
+ maybe_soft_fail = true;
+ soft_fail_nunits_vectype = nunits_vectype;
+ }
+
+ gcc_assert (vectype);
+ *node_vectype = vectype;
+
/* For every stmt in NODE find its def stmt/s. */
stmt_vec_info stmt_info;
FOR_EACH_VEC_ELT (stmts, i, stmt_info)
@@ -1144,7 +1167,7 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
}
gcall *call_stmt = dyn_cast <gcall *> (stmt);
- lhs = gimple_get_lhs (stmt);
+ tree lhs = gimple_get_lhs (stmt);
if (lhs == NULL_TREE
&& (!call_stmt
|| !gimple_call_internal_p (stmt)
@@ -1161,30 +1184,6 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
return false;
}
- tree vectype, nunits_vectype;
- if (!vect_get_vector_types_for_stmt (vinfo, stmt_info, &vectype,
- &nunits_vectype, group_size))
- {
- if (is_a <bb_vec_info> (vinfo) && i != 0)
- continue;
- /* Fatal mismatch. */
- matches[0] = false;
- return false;
- }
- /* Record nunits required but continue analysis, producing matches[]
- as if nunits was not an issue. This allows splitting of groups
- to happen. */
- if (nunits_vectype
- && !vect_record_max_nunits (vinfo, stmt_info, group_size,
- nunits_vectype, max_nunits))
- {
- gcc_assert (is_a <bb_vec_info> (vinfo));
- maybe_soft_fail = true;
- soft_fail_nunits_vectype = nunits_vectype;
- }
-
- gcc_assert (vectype);
-
if (call_stmt)
{
combined_fn cfn = gimple_call_combined_fn (call_stmt);
@@ -1241,7 +1240,7 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
/* Check the operation. */
if (i == 0)
{
- *node_vectype = vectype;
+ first_lhs = lhs;
first_stmt_code = rhs_code;
first_stmt_ldst_p = ldst_p;
first_stmt_phi_p = phi_p;
@@ -1432,7 +1431,9 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
}
}
- if (!types_compatible_p (vectype, *node_vectype))
+ if (first_lhs
+ && lhs
+ && !types_compatible_p (TREE_TYPE (lhs), TREE_TYPE (first_lhs)))
{
if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,