[gcc r15-1375] tree-optimization/115508 - fix ICE with SLP scheduling and extern vector

Richard Biener rguenth@gcc.gnu.org
Mon Jun 17 12:40:06 GMT 2024


https://gcc.gnu.org/g:65e72b95c63a5501cf1482f3814ae8c8e672bf06

commit r15-1375-g65e72b95c63a5501cf1482f3814ae8c8e672bf06
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Jun 17 14:36:56 2024 +0200

    tree-optimization/115508 - fix ICE with SLP scheduling and extern vector
    
    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.

Diff:
---
 gcc/testsuite/gcc.target/i386/pr115508.c | 15 +++++++++++++++
 gcc/tree-vect-slp.cc                     |  1 +
 2 files changed, 16 insertions(+)

diff --git a/gcc/testsuite/gcc.target/i386/pr115508.c b/gcc/testsuite/gcc.target/i386/pr115508.c
new file mode 100644
index 000000000000..a97b2007f7a9
--- /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 7e3d0107b4e7..7d18b5bfee5d 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -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))
 	{


More information about the Gcc-cvs mailing list