When we first detect a grouped load but later dis-associate it we
only set DR_GROUP_FIRST_ELEMENT to NULL, indicating it is not a
STMT_VINFO_GROUPED_ACCESS but leave DR_GROUP_NEXT_ELEMENT set. This
causes a stray DR_GROUP_NEXT_ELEMENT access in get_group_load_store_type
to go wrong, indicating a load isn't single_element_p when it actually
is, leading to wrong classification and an ICE.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
PR tree-optimization/117041
* tree-vect-stmts.cc (get_group_load_store_type): Only
check DR_GROUP_NEXT_ELEMENT for STMT_VINFO_GROUPED_ACCESS.
* gcc.dg/torture/pr117041.c: New testcase.
---
gcc/testsuite/gcc.dg/torture/pr117041.c | 10 ++++++++++
gcc/tree-vect-stmts.cc | 6 ++++--
2 files changed, 14 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/torture/pr117041.c
diff --git a/gcc/testsuite/gcc.dg/torture/pr117041.c
b/gcc/testsuite/gcc.dg/torture/pr117041.c
new file mode 100644
index 00000000000..09dbbf4c00f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr117041.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+
+unsigned short a;
+int b, c[7][6];
+int main() {
+ for (a = 0; a < 6; a++)
+ for (b = 5; b; b--)
+ c[a][b] = c[a+1][b];
+ return 0;
+}
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index 43358767934..ad4a3141ab8 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -1991,21 +1991,23 @@ get_group_load_store_type (vec_info *vinfo,
stmt_vec_info stmt_info,
stmt_vec_info first_stmt_info;
unsigned int group_size;
unsigned HOST_WIDE_INT gap;
+ bool single_element_p;
if (STMT_VINFO_GROUPED_ACCESS (stmt_info))
{
first_stmt_info = DR_GROUP_FIRST_ELEMENT (stmt_info);
group_size = DR_GROUP_SIZE (first_stmt_info);
gap = DR_GROUP_GAP (first_stmt_info);
+ single_element_p = (stmt_info == first_stmt_info
+ && !DR_GROUP_NEXT_ELEMENT (stmt_info));
}
else
{
first_stmt_info = stmt_info;
group_size = 1;
gap = 0;
+ single_element_p = true;
}
dr_vec_info *first_dr_info = STMT_VINFO_DR_INFO (first_stmt_info);
- bool single_element_p = (stmt_info == first_stmt_info
- && !DR_GROUP_NEXT_ELEMENT (stmt_info));
poly_uint64 nunits = TYPE_VECTOR_SUBPARTS (vectype);
/* True if the vectorized statements would access beyond the last
--
2.43.0