]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/115254 - don't account single-lane SLP against discovery limit
authorRichard Biener <rguenther@suse.de>
Fri, 29 Sep 2023 13:12:54 +0000 (15:12 +0200)
committerRichard Biener <rguenther@suse.de>
Tue, 28 May 2024 09:47:05 +0000 (11:47 +0200)
The following avoids accounting single-lane SLP to the discovery
limit.  As the two testcases show this makes discovery fail,
unfortunately even not the same across targets.  The following
should fix two FAILs for GCN as a side-effect.

PR tree-optimization/115254
* tree-vect-slp.cc (vect_build_slp_tree): Only account
multi-lane SLP to limit.

* gcc.dg/vect/slp-cond-2-big-array.c: Expect 4 times SLP.
* gcc.dg/vect/slp-cond-2.c: Likewise.

gcc/testsuite/gcc.dg/vect/slp-cond-2-big-array.c
gcc/testsuite/gcc.dg/vect/slp-cond-2.c
gcc/tree-vect-slp.cc

index cb7eb94b3a3ba207d513e3e701cd1c9908000a01..9a9f63c0b8d094ee3f19b783da6bd916a6af237f 100644 (file)
@@ -128,4 +128,4 @@ main ()
   return 0;
 }
 
-/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 4 "vect" } } */
index 1dcee46cd9540690521df07c9cacb608e37b62b7..08bbb3dbec61909f0b07ddf09bcc34f3bb151bc9 100644 (file)
@@ -128,4 +128,4 @@ main ()
   return 0;
 }
 
-/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 4 "vect" } } */
index c7ed520b62942cc321cb3792d9efa0f6d0a78ed7..7a963e28063dba3a1a7ee7e780815da0cdf45398 100644 (file)
@@ -1725,21 +1725,26 @@ vect_build_slp_tree (vec_info *vinfo,
   SLP_TREE_SCALAR_STMTS (res) = stmts;
   bst_map->put (stmts.copy (), res);
 
-  if (*limit == 0)
+  /* Single-lane SLP doesn't have the chance of run-away, do not account
+     it to the limit.  */
+  if (stmts.length () > 1)
     {
-      if (dump_enabled_p ())
-       dump_printf_loc (MSG_NOTE, vect_location,
-                        "SLP discovery limit exceeded\n");
-      /* Mark the node invalid so we can detect those when still in use
-        as backedge destinations.  */
-      SLP_TREE_SCALAR_STMTS (res) = vNULL;
-      SLP_TREE_DEF_TYPE (res) = vect_uninitialized_def;
-      res->failed = XNEWVEC (bool, group_size);
-      memset (res->failed, 0, sizeof (bool) * group_size);
-      memset (matches, 0, sizeof (bool) * group_size);
-      return NULL;
+      if (*limit == 0)
+       {
+         if (dump_enabled_p ())
+           dump_printf_loc (MSG_NOTE, vect_location,
+                            "SLP discovery limit exceeded\n");
+         /* Mark the node invalid so we can detect those when still in use
+            as backedge destinations.  */
+         SLP_TREE_SCALAR_STMTS (res) = vNULL;
+         SLP_TREE_DEF_TYPE (res) = vect_uninitialized_def;
+         res->failed = XNEWVEC (bool, group_size);
+         memset (res->failed, 0, sizeof (bool) * group_size);
+         memset (matches, 0, sizeof (bool) * group_size);
+         return NULL;
+       }
+      --*limit;
     }
-  --*limit;
 
   if (dump_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location,