https://gcc.gnu.org/g:fa0f551f3931529d5be72140f5a37ed02d0e0366

commit fa0f551f3931529d5be72140f5a37ed02d0e0366
Author: Richard Biener <rguent...@suse.de>
Date:   Fri Sep 29 15:12:54 2023 +0200

    Do not account single-lane SLP graphs against discovery limit
    
    The following avoids accounting single-lane SLP to the discovery
    limit.  Even when raising it the attempt of forming multi-lane SLP
    can exhaust the limit before we fall back to single-lane.
    
            * tree-vect-slp.cc (vect_build_slp_tree): Only account
            multi-lane SLP to limit.

Diff:
---
 gcc/tree-vect-slp.cc | 31 ++++++++++++++++++-------------
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index 66c8fa38979f..3a078b253df5 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -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,

Reply via email to