diff mbox series

tree-optimization/115508 - fix ICE with SLP scheduling and extern vector

Message ID 20240617123902.824FD139AB@imap1.dmz-prg2.suse.org
State New
Headers show
Series tree-optimization/115508 - fix ICE with SLP scheduling and extern vector | expand

Commit Message

Richard Biener June 17, 2024, 12:39 p.m. UTC
When there's a permute after an extern vector we can run into a case
that didn't consider the scheduled node being a permute which lacks
a representative.

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

	PR tree-optimization/115508
	* tree-vect-slp.cc (vect_schedule_slp_node): Guard check on
	representative.

	* gcc.target/i386/pr115508.c: New testcase.
---
 gcc/testsuite/gcc.target/i386/pr115508.c | 15 +++++++++++++++
 gcc/tree-vect-slp.cc                     |  1 +
 2 files changed, 16 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/i386/pr115508.c
diff mbox series

Patch

diff --git a/gcc/testsuite/gcc.target/i386/pr115508.c b/gcc/testsuite/gcc.target/i386/pr115508.c
new file mode 100644
index 00000000000..a97b2007f7a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr115508.c
@@ -0,0 +1,15 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=znver1" } */
+
+typedef long long v4di __attribute__((vector_size(4 * sizeof (long long))));
+
+v4di vec_var;
+extern long long array1[];
+long long g(void)
+{
+  int total_error_4 = 0;
+  total_error_4 += array1 [0] + array1 [1] + array1 [2] + array1 [3];
+  v4di t = vec_var;
+  long long iorvar = t [1] | t [0] | t [2] | t [3];
+  return iorvar + total_error_4;
+}
diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index 38e7fadb679..6ef04b14dd8 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -9674,6 +9674,7 @@  vect_schedule_slp_node (vec_info *vinfo,
 	  si = gsi_after_labels (vinfo->bbs[0]);
 	}
       else if (is_a <bb_vec_info> (vinfo)
+	       && SLP_TREE_CODE (node) != VEC_PERM_EXPR
 	       && gimple_bb (last_stmt) != gimple_bb (stmt_info->stmt)
 	       && gimple_could_trap_p (stmt_info->stmt))
 	{