With excess lanes present we miscount the number of copies of the
SLP elements which eventually results in ctor_seq stmts not being
emitted.
Bootstrapped and tested on x86_64-unknown-linux-gnu and
aarch64-linux-gnu, pushed.
PR tree-optimization/127195
* tree-vect-slp.cc (vect_create_constant_vectors):
Properly compute number_of_copies, assert we end up
on a vector boundary.
* gcc.dg/vect/vect-pr127195.c: New testcase.
---
gcc/testsuite/gcc.dg/vect/vect-pr127195.c | 21 +++++++++++++++++++++
gcc/tree-vect-slp.cc | 4 +++-
2 files changed, 24 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.dg/vect/vect-pr127195.c
diff --git a/gcc/testsuite/gcc.dg/vect/vect-pr127195.c
b/gcc/testsuite/gcc.dg/vect/vect-pr127195.c
new file mode 100644
index 00000000000..57da05e4837
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-pr127195.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+
+typedef struct {
+ unsigned bold : 1;
+ unsigned : 16;
+} vbi_char;
+typedef struct {
+ vbi_char text[];
+} vbi_page;
+vbi_page enhance_pg;
+vbi_char *enhance_acp = &enhance_pg.text[1];
+int enhance_col, enhance_column;
+void enhance()
+{
+ for (;;) {
+ int bold;
+ enhance_col = enhance_column;
+ for (; enhance_col; enhance_col++)
+ enhance_acp[enhance_col].bold = bold;
+ }
+}
diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index 3e1bfd000f1..665a433a48f 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -10978,7 +10978,7 @@ vect_create_constant_vectors (vec_info *vinfo, slp_tree
op_node)
if (!TYPE_VECTOR_SUBPARTS (vector_type).is_constant (&nunits))
nunits = group_size;
- number_of_copies = nunits * number_of_vectors / group_size;
+ number_of_copies = (nunits * number_of_vectors - excess_elts) / group_size;
constant_p = true;
tree uniform_elt = NULL_TREE;
@@ -11130,6 +11130,8 @@ vect_create_constant_vectors (vec_info *vinfo, slp_tree
op_node)
}
}
+ gcc_assert (number_of_places_left_in_vector == nunits);
+
/* Since the vectors are created in the reverse order, we should invert
them. */
vec_num = voprnds.length ();
--
2.51.0