The soft-fail path due to BB SLP unrolling can fail hard as well,
but there's no need to compute match[] when we just discard it
anyway.

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

I'll probably re-order to the beginning of the series as well, or
drop as likely conflicting with predicated tails.

        * tree-vect-slp.cc (vect_build_slp_tree_1): Hard-fail early
        due to BB SLP unrolling.
---
 gcc/tree-vect-slp.cc | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index c0303627579..70140d72fdf 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -1685,7 +1685,7 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char 
*swap,
       return false;
     }
   bool maybe_soft_fail = false;
-  tree soft_fail_nunits_vectype = NULL_TREE;
+  unsigned HOST_WIDE_INT const_nunits = 0;
   /* Record nunits required but continue analysis, producing matches[]
      as if nunits was not an issue.  This allows splitting of groups
      to happen.  */
@@ -1694,8 +1694,14 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char 
*swap,
                                  nunits_vectype, max_nunits))
     {
       gcc_assert (is_a <bb_vec_info> (vinfo));
+      if (!TYPE_VECTOR_SUBPARTS (nunits_vectype).is_constant (&const_nunits)
+         || const_nunits > group_size)
+       {
+         /* Fatal mismatch.  */
+         matches[0] = false;
+         return false;
+       }
       maybe_soft_fail = true;
-      soft_fail_nunits_vectype = nunits_vectype;
     }
 
   gcc_assert (vectype || !gimple_get_lhs (first_stmt_info->stmt));
@@ -1715,19 +1721,10 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char 
*swap,
 
   if (maybe_soft_fail)
     {
-      unsigned HOST_WIDE_INT const_nunits;
-      if (!TYPE_VECTOR_SUBPARTS
-           (soft_fail_nunits_vectype).is_constant (&const_nunits)
-         || const_nunits > group_size)
-       /* Fatal mismatch.  */
-       matches[0] = false;
-      else
-       {
-         /* With constant vector elements simulate a mismatch at the
-            point we need to split.  */
-         unsigned tail = group_size & (const_nunits - 1);
-         memset (&matches[group_size - tail], 0, sizeof (bool) * tail);
-       }
+      /* With constant vector elements simulate a mismatch at the
+        point we need to split.  */
+      unsigned tail = group_size & (const_nunits - 1);
+      memset (&matches[group_size - tail], 0, sizeof (bool) * tail);
       return false;
     }
 
-- 
2.51.0

Reply via email to