]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/115508 - fix ICE with SLP scheduling and extern vector
authorRichard Biener <rguenther@suse.de>
Mon, 17 Jun 2024 12:36:56 +0000 (14:36 +0200)
committerRichard Biener <rguenther@suse.de>
Mon, 17 Jun 2024 12:39:30 +0000 (14:39 +0200)
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.

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 [new file with mode: 0644]
gcc/tree-vect-slp.cc

diff --git a/gcc/testsuite/gcc.target/i386/pr115508.c b/gcc/testsuite/gcc.target/i386/pr115508.c
new file mode 100644 (file)
index 0000000..a97b200
--- /dev/null
@@ -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;
+}
index 7e3d0107b4e71a26647009071cb8ae31ff83dceb..7d18b5bfee5d24cc831829c3ac0863593893088a 100644 (file)
@@ -9669,6 +9669,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))
        {