The following fixes a segfault that appeared with a patch applying
additional permutes to a reduction SLP instance root.

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

        * tree-vect-loop.cc (vect_analyze_loop_2): Deal with NULL
        element in SLP_TREE_SCALAR_STMTS.
---
 gcc/tree-vect-loop.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 77c9e15601b..7bb1c6baee8 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -2598,7 +2598,7 @@ again:
 
       stmt_vec_info vinfo;
       vinfo = SLP_TREE_SCALAR_STMTS (SLP_INSTANCE_TREE (instance))[0];
-      if (! STMT_VINFO_GROUPED_ACCESS (vinfo))
+      if (!vinfo || !STMT_VINFO_GROUPED_ACCESS (vinfo))
        continue;
       vinfo = DR_GROUP_FIRST_ELEMENT (vinfo);
       unsigned int size = DR_GROUP_SIZE (vinfo);
-- 
2.51.0

Reply via email to