]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Reject single lane vector types for SLP build
authorRichard Biener <rguenther@suse.de>
Thu, 10 Jul 2025 11:04:00 +0000 (13:04 +0200)
committerRichard Biener <rguenther@suse.de>
Thu, 17 Jul 2025 06:26:40 +0000 (08:26 +0200)
The following makes us never consider vector(1) T types for
vectorization and ensures this during SLP build.  This is a
long-standing issue for BB vectorization and when we remove
early loop vector type setting we lose the single place we have
that rejects this for loops.

Once we implement partial loop vectorization we should revisit
this, but then use the original scalar types for the unvectorized
parts.

* tree-vect-slp.cc (vect_build_slp_tree_1): Reject
single-lane vector types.

* gcc.dg/vect/bb-slp-39.c: Adjust.

gcc/testsuite/gcc.dg/vect/bb-slp-39.c
gcc/tree-vect-slp.cc

index f05ce8f2847be1331ed63499c19c0b4f55cff4fa..255bb1095dc5bd1398f2de1afcd82168d074b29d 100644 (file)
@@ -16,5 +16,4 @@ void foo (double *p)
 }
 
 /* See that we vectorize three SLP instances.  */
-/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "slp2" { target { ! { s390*-*-* riscv*-*-* } } } } } */
-/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 5 "slp2" { target {   s390*-*-* riscv*-*-* } } } } */
+/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "slp2" } } */
index ad75386926a8f99dd88188684f61bd954fa25cba..fe67d4dbc46ccf78d2df17eb02fcfa917d5c51e2 100644 (file)
@@ -1114,6 +1114,16 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
       matches[0] = false;
       return false;
     }
+  if (is_a <bb_vec_info> (vinfo)
+      && known_le (TYPE_VECTOR_SUBPARTS (vectype), 1U))
+    {
+      if (dump_enabled_p ())
+       dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                        "Build SLP failed: not using single lane "
+                        "vector type %T\n", vectype);
+      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.  */