[2/2] tree-optimization/116083 - SLP discovery slowness
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gcc_check--master-aarch64 |
success
|
Test passed
|
linaro-tcwg-bot/tcwg_gcc_build--master-arm |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gcc_check--master-arm |
success
|
Test passed
|
Commit Message
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.
Bootstrapped and tested on x86_64-unknown-linux-gnu, will push
tomorrow.
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.
---
gcc/tree-vect-slp.cc | 58 ++++++++++++++++++--------------------------
1 file changed, 23 insertions(+), 35 deletions(-)
@@ -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)
@@ -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,6 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
/* Check the operation. */
if (i == 0)
{
- *node_vectype = vectype;
first_stmt_code = rhs_code;
first_stmt_ldst_p = ldst_p;
first_stmt_phi_p = phi_p;
@@ -1431,16 +1429,6 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
continue;
}
}
-
- if (!types_compatible_p (vectype, *node_vectype))
- {
- if (dump_enabled_p ())
- dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
- "Build SLP failed: different vector type "
- "in %G", stmt);
- /* Mismatch. */
- continue;
- }
}
/* Grouped store or load. */