There's a mismatch in the node checked (oops) in
vect_slp_analyze_node_operations causing a later ICE.

Bootstrapped and tested on aarch64-linux-gnu, pushed.

        PR tree-optimization/127245
        * tree-vect-slp.cc (vect_slp_analyze_node_operations): Check
        whether child passes vect_get_num_copies_for_invariant.

        * gcc.dg/vect/vect-pr127245.c: New testcase.
---
 gcc/testsuite/gcc.dg/vect/vect-pr127245.c | 13 +++++++++++++
 gcc/tree-vect-slp.cc                      |  2 +-
 2 files changed, 14 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.dg/vect/vect-pr127245.c

diff --git a/gcc/testsuite/gcc.dg/vect/vect-pr127245.c 
b/gcc/testsuite/gcc.dg/vect/vect-pr127245.c
new file mode 100644
index 00000000000..6812642629c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-pr127245.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-march=armv8.3-a+sve" { target aarch64-*-* } } */
+
+struct vbi_char {
+  unsigned bold : 1;
+  unsigned : 16;
+} ;
+struct vbi_char *v;
+void f(int l, bool bold)
+{
+  for (int i = 0; i < l; i++)
+    v[i].bold = bold;
+}
diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index 8b60cfe6f4a..3d8188ba1e4 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -9246,7 +9246,7 @@ vect_slp_analyze_node_operations (vec_info *vinfo, 
slp_tree node,
 
          /* Make sure we can generate them and then cost them.  */
          unsigned nvectors, excess_elts;
-         if (!vect_get_num_copies_for_invariant (vinfo, node, &nvectors,
+         if (!vect_get_num_copies_for_invariant (vinfo, child, &nvectors,
                                                  &excess_elts))
            return false;
          vect_prologue_cost_for_slp (child, nvectors, cost_vec);
-- 
2.51.0

Reply via email to