The following makes sure to apply forced splitting of groups for
firced single-lane SLP only when the group being analyzed has more
than one lane.  This avoids an out-of-bound access to matches[].

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

        PR tree-optimization/116810
        * tree-vect-slp.cc (vect_build_slp_instance): Onlu force
        splitting for group_size > 1.
---
 gcc/tree-vect-slp.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index 600987dd6e5..c24376688f5 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -3715,7 +3715,7 @@ vect_build_slp_instance (vec_info *vinfo,
   unsigned i;
 
   slp_tree node = NULL;
-  if (force_single_lane)
+  if (group_size > 1 && force_single_lane)
     {
       matches[0] = true;
       matches[1] = false;
-- 
2.43.0

Reply via email to