aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vect-slp.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2020-10-27 11:03:27 +0100
committerRichard Biener <rguenther@suse.de>2020-10-27 13:16:35 +0100
commit5af1e827bbb624eb28f80d2c5e0da46185af3708 (patch)
tree14498c1e161ef861cfe7bc4b6f7e72e1eb3c39e0 /gcc/tree-vect-slp.c
parent4e6e941db7ced1fb967beed5f15b69b4d56bce61 (diff)
downloadgcc-5af1e827bbb624eb28f80d2c5e0da46185af3708.zip
gcc-5af1e827bbb624eb28f80d2c5e0da46185af3708.tar.gz
gcc-5af1e827bbb624eb28f80d2c5e0da46185af3708.tar.bz2
Avoid uniform lane BB vectorization
This makes sure to use splats early when facing uniform internal operands in BB SLP discovery rather than relying on the late heuristincs re-building nodes from scratch. 2020-10-27 Richard Biener <rguenther@suse.de> * tree-vect-slp.c (vect_build_slp_tree_2): When vectorizing BBs splat uniform operands and stop SLP discovery. * gcc.target/i386/pr95866-1.c: Adjust.
Diffstat (limited to 'gcc/tree-vect-slp.c')
-rw-r--r--gcc/tree-vect-slp.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index 894f045..85865da 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -1486,6 +1486,28 @@ vect_build_slp_tree_2 (vec_info *vinfo,
continue;
}
+ if (is_a <bb_vec_info> (vinfo)
+ && oprnd_info->first_dt == vect_internal_def)
+ {
+ /* For BB vectorization, if all defs are the same do not
+ bother to continue the build along the single-lane
+ graph but use a splat of the scalar value. */
+ stmt_vec_info first_def = oprnd_info->def_stmts[0];
+ for (j = 1; j < group_size; ++j)
+ if (oprnd_info->def_stmts[j] != first_def)
+ break;
+ if (j == group_size
+ /* But avoid doing this for loads where we may be
+ able to CSE things. */
+ && !gimple_vuse (first_def->stmt))
+ {
+ if (dump_enabled_p ())
+ dump_printf_loc (MSG_NOTE, vect_location,
+ "Using a splat of the uniform operand\n");
+ oprnd_info->first_dt = vect_external_def;
+ }
+ }
+
if (oprnd_info->first_dt != vect_internal_def
&& oprnd_info->first_dt != vect_reduction_def
&& oprnd_info->first_dt != vect_induction_def)