aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2020-06-25 12:47:20 +0200
committerRichard Biener <rguenther@suse.de>2020-06-25 15:56:06 +0200
commit628b78f9794a2eefcbc578011806bfa8e09b9ef7 (patch)
tree5773155caa47cfcec12e00f2a4edd263437174e9 /gcc
parent8005a3e4e7a643ff78086081a3385775924fe828 (diff)
downloadgcc-628b78f9794a2eefcbc578011806bfa8e09b9ef7.zip
gcc-628b78f9794a2eefcbc578011806bfa8e09b9ef7.tar.gz
gcc-628b78f9794a2eefcbc578011806bfa8e09b9ef7.tar.bz2
tree-optimization/95839 - allow CTOR vectorization without loads
This removes a premature check for enough datarefs in a basic-block before we consider vectorizing it which leaves basic-blocks with just vectorizable vector constructors unvectorized. The check is effectively done by the following check for store groups which then also include constructors. 2020-06-25 Richard Biener <rguenther@suse.de> PR tree-optimization/95839 * tree-vect-slp.c (vect_slp_analyze_bb_1): Remove premature check on the number of datarefs. * gcc.dg/vect/bb-slp-pr95839.c: New testcase.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.dg/vect/bb-slp-pr95839.c13
-rw-r--r--gcc/tree-vect-slp.c15
2 files changed, 16 insertions, 12 deletions
diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr95839.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr95839.c
new file mode 100644
index 0000000..0bfba01
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr95839.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_float } */
+/* { dg-additional-options "-w -Wno-psabi" } */
+
+typedef float __attribute__((vector_size(16))) v4f32;
+
+v4f32 f(v4f32 a, v4f32 b)
+{
+ /* Check that we vectorize this CTOR without any loads. */
+ return (v4f32){a[0] + b[0], a[1] + b[1], a[2] + b[2], a[3] + b[3]};
+}
+
+/* { dg-final { scan-tree-dump "basic block vectorized" "slp2" } } */
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index 5883ec5..46a75f1 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -3149,15 +3149,6 @@ vect_slp_analyze_bb_1 (bb_vec_info bb_vinfo, int n_stmts, bool &fatal)
return false;
}
- if (BB_VINFO_DATAREFS (bb_vinfo).length () < 2)
- {
- if (dump_enabled_p ())
- dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
- "not vectorized: not enough data-refs in "
- "basic block.\n");
- return false;
- }
-
if (!vect_analyze_data_ref_accesses (bb_vinfo))
{
if (dump_enabled_p ())
@@ -3169,9 +3160,9 @@ vect_slp_analyze_bb_1 (bb_vec_info bb_vinfo, int n_stmts, bool &fatal)
vect_slp_check_for_constructors (bb_vinfo);
- /* If there are no grouped stores in the region there is no need
- to continue with pattern recog as vect_analyze_slp will fail
- anyway. */
+ /* If there are no grouped stores and no constructors in the region
+ there is no need to continue with pattern recog as vect_analyze_slp
+ will fail anyway. */
if (bb_vinfo->grouped_stores.is_empty ())
{
if (dump_enabled_p ())