gcc/fix-ICE-in-eliminate_stmt.patch
2020-09-21 19:40:05 +08:00

163 lines
5.3 KiB
Diff

This backport contains 2 patchs from gcc main stream tree.
The commit id of these patchs list as following in the order of time.
0001-Tweak-gcc.dg-vect-bb-slp-4-01-.c-PR92366.patch
3771033244b3ee1b53a8a00d734580b16384fdd3
0001-tree-vect-slp.c-vect_analyze_slp_instance-Dump-const.patch
140ee00a961fda084c1b4b3f0e7e489a917858f7
diff -Nurp a/gcc/testsuite/gcc.dg/vect/bb-slp-40.c b/gcc/testsuite/gcc.dg/vect/bb-slp-40.c
--- a/gcc/testsuite/gcc.dg/vect/bb-slp-40.c 2020-09-14 21:24:20.899694710 +0800
+++ b/gcc/testsuite/gcc.dg/vect/bb-slp-40.c 2020-09-15 20:54:05.456027442 +0800
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O3 -fdump-tree-slp-all" } */
+/* { dg-additional-options "-fvect-cost-model=dynamic" } */
/* { dg-require-effective-target vect_int } */
char g_d[1024], g_s1[1024], g_s2[1024];
@@ -30,5 +30,5 @@ void foo(void)
}
/* See that we vectorize an SLP instance. */
-/* { dg-final { scan-tree-dump-times "Found vectorizable constructor" 1 "slp1" } } */
-/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "slp1" } } */
+/* { dg-final { scan-tree-dump "Analyzing vectorizable constructor" "slp1" } } */
+/* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "slp1" } } */
diff -Nurp a/gcc/testsuite/gcc.dg/vect/bb-slp-41.c b/gcc/testsuite/gcc.dg/vect/bb-slp-41.c
--- a/gcc/testsuite/gcc.dg/vect/bb-slp-41.c 2020-09-14 21:24:20.899694710 +0800
+++ b/gcc/testsuite/gcc.dg/vect/bb-slp-41.c 2020-09-15 20:54:10.424087539 +0800
@@ -1,10 +1,9 @@
-/* { dg-do run } */
-/* { dg-options "-O3 -fdump-tree-slp-all -fno-vect-cost-model" } */
/* { dg-require-effective-target vect_int } */
#define ARR_SIZE 1000
-void foo (int *a, int *b)
+void __attribute__((optimize (0)))
+foo (int *a, int *b)
{
int i;
for (i = 0; i < (ARR_SIZE - 2); ++i)
@@ -56,6 +55,4 @@ int main ()
return 0;
}
-/* See that we vectorize an SLP instance. */
-/* { dg-final { scan-tree-dump-times "Found vectorizable constructor" 12 "slp1" } } */
-/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 4 "slp1" } } */
+/* { dg-final { scan-tree-dump-not "vectorizing stmts using SLP" "slp1" } } */
diff -Nurp a/gcc/testsuite/gcc.dg/vect/bb-slp-42.c b/gcc/testsuite/gcc.dg/vect/bb-slp-42.c
--- a/gcc/testsuite/gcc.dg/vect/bb-slp-42.c 1970-01-01 08:00:00.000000000 +0800
+++ b/gcc/testsuite/gcc.dg/vect/bb-slp-42.c 2020-09-15 20:54:14.724139555 +0800
@@ -0,0 +1,48 @@
+/* { dg-require-effective-target vect_int } */
+/* { dg-require-effective-target vect_perm } */
+
+#include "tree-vect.h"
+
+#define ARR_SIZE 1024
+
+void __attribute__((noipa))
+foo (int a[][ARR_SIZE], int *b)
+{
+ int i;
+ for (i = 0; i < ARR_SIZE; ++i)
+ {
+ a[0][i] += b[0];
+ a[1][i] += b[1];
+ a[2][i] += b[2];
+ a[3][i] += b[3];
+ }
+}
+
+int
+main ()
+{
+ int a[4][ARR_SIZE];
+ int b[4];
+
+ check_vect ();
+
+ for (int i = 0; i < 4; ++i)
+ {
+ b[i] = 20 * i;
+ for (int j = 0; j < ARR_SIZE; ++j)
+ a[i][j] = (i + 1) * ARR_SIZE - j;
+ }
+
+ foo (a, b);
+
+ for (int i = 0; i < 4; ++i)
+ for (int j = 0; j < ARR_SIZE; ++j)
+ if (a[i][j] != (i + 1) * ARR_SIZE - j + 20 * i)
+ __builtin_abort ();
+
+ return 0;
+
+}
+
+/* See that we do not try to vectorize the uniform CTORs. */
+/* { dg-final { scan-tree-dump-not "Analyzing vectorizable constructor" "slp1" } } */
diff -Nurp a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
--- a/gcc/tree-vect-slp.c 2020-09-14 21:24:20.983695752 +0800
+++ b/gcc/tree-vect-slp.c 2020-09-14 16:13:11.077779069 +0800
@@ -2106,6 +2106,10 @@ vect_analyze_slp_instance (vec_info *vin
else
return false;
}
+ if (dump_enabled_p ())
+ dump_printf_loc (MSG_NOTE, vect_location,
+ "Analyzing vectorizable constructor: %G\n",
+ stmt_info->stmt);
}
else
{
@@ -3049,31 +3053,22 @@ vect_slp_check_for_constructors (bb_vec_
gimple_stmt_iterator gsi;
for (gsi = bb_vinfo->region_begin;
- gsi_stmt (gsi) != gsi_stmt (bb_vinfo->region_end); gsi_next (&gsi))
+ gsi_stmt (gsi) != gsi_stmt (bb_vinfo->region_end); gsi_next (&gsi))
{
- gimple *stmt = gsi_stmt (gsi);
-
- if (is_gimple_assign (stmt)
- && gimple_assign_rhs_code (stmt) == CONSTRUCTOR
- && TREE_CODE (gimple_assign_lhs (stmt)) == SSA_NAME
- && TREE_CODE (TREE_TYPE (gimple_assign_lhs (stmt))) == VECTOR_TYPE)
- {
- tree rhs = gimple_assign_rhs1 (stmt);
-
- if (CONSTRUCTOR_NELTS (rhs) == 0)
- continue;
-
- poly_uint64 subparts = TYPE_VECTOR_SUBPARTS (TREE_TYPE (rhs));
+ gassign *stmt = dyn_cast <gassign *> (gsi_stmt (gsi));
+ if (!stmt || gimple_assign_rhs_code (stmt) != CONSTRUCTOR)
+ continue;
- if (maybe_ne (subparts, CONSTRUCTOR_NELTS (rhs)))
- continue;
+ tree rhs = gimple_assign_rhs1 (stmt);
+ if (!VECTOR_TYPE_P (TREE_TYPE (rhs))
+ || maybe_ne (TYPE_VECTOR_SUBPARTS (TREE_TYPE (rhs)),
+ CONSTRUCTOR_NELTS (rhs))
+ || VECTOR_TYPE_P (TREE_TYPE (CONSTRUCTOR_ELT (rhs, 0)->value))
+ || uniform_vector_p (rhs))
+ continue;
- if (dump_enabled_p ())
- dump_printf_loc (MSG_NOTE, vect_location,
- "Found vectorizable constructor: %G\n", stmt);
- stmt_vec_info stmt_info = bb_vinfo->lookup_stmt (stmt);
- BB_VINFO_GROUPED_STORES (bb_vinfo).safe_push (stmt_info);
- }
+ stmt_vec_info stmt_info = bb_vinfo->lookup_stmt (stmt);
+ BB_VINFO_GROUPED_STORES (bb_vinfo).safe_push (stmt_info);
}
}