aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFei Yang <felix.yang@huawei.com>2020-04-27 11:08:04 +0100
committerRichard Sandiford <richard.sandiford@arm.com>2020-04-27 11:08:04 +0100
commit5328710be314dee43da8027dbff547d48b85e35e (patch)
tree0f46d7f00baf8311a781d1d411cb858da977bab2
parentacdf733634745548c0167c40bad80e6140ac2eeb (diff)
downloadgcc-5328710be314dee43da8027dbff547d48b85e35e.zip
gcc-5328710be314dee43da8027dbff547d48b85e35e.tar.gz
gcc-5328710be314dee43da8027dbff547d48b85e35e.tar.bz2
forwprop: Fix ICE when building an identity constructor [PR94784]
In the testcase for PR94784, we have two vectors with the same ABI identity but with different TYPE_MODEs. It would be better to flip the assert around so that it checks that the two vectors have equal TYPE_VECTOR_SUBPARTS and that converting the corresponding element types is a useless_type_conversion_p. 2020-04-27 Felix Yang <felix.yang@huawei.com> gcc/ PR tree-optimization/94784 * tree-ssa-forwprop.c (simplify_vector_constructor): Flip the assert around so that it checks that the two vectors have equal TYPE_VECTOR_SUBPARTS and that converting the corresponding element types is a useless_type_conversion_p. gcc/testsuite/ PR tree-optimization/94784 * gcc.dg/pr94784.c: New test.
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/pr94784.c16
-rw-r--r--gcc/tree-ssa-forwprop.c10
4 files changed, 37 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2f65b5d..bd5e95a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2020-04-27 Felix Yang <felix.yang@huawei.com>
+
+ PR tree-optimization/94784
+ * tree-ssa-forwprop.c (simplify_vector_constructor): Flip the
+ assert around so that it checks that the two vectors have equal
+ TYPE_VECTOR_SUBPARTS and that converting the corresponding element
+ types is a useless_type_conversion_p.
+
2020-04-27 Szabolcs Nagy <szabolcs.nagy@arm.com>
PR target/94515
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ee7c95d..f61955d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2020-04-27 Felix Yang <felix.yang@huawei.com>
+
+ PR tree-optimization/94784
+ * gcc.dg/pr94784.c: New test.
+
2020-04-27 Szabolcs Nagy <szabolcs.nagy@arm.com>
PR target/94515
diff --git a/gcc/testsuite/gcc.dg/pr94784.c b/gcc/testsuite/gcc.dg/pr94784.c
new file mode 100644
index 0000000..df6972f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr94784.c
@@ -0,0 +1,16 @@
+/* { dg-do compile { target aarch64*-*-* } } */
+/* { dg-options "-O2 -ftree-slp-vectorize -march=armv8.2-a+sve -msve-vector-bits=256" } */
+
+typedef short __attribute__((vector_size (8))) v4hi;
+
+typedef union U4HI { v4hi v; short a[4]; } u4hi;
+
+short a[4];
+
+void pass_v4hi (v4hi v) {
+ int j;
+ u4hi u;
+ u.v = v;
+ for (j = 0; j < 4; j++)
+ a[j] = u.a[j];
+};
diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c
index 8ee5450..4358732 100644
--- a/gcc/tree-ssa-forwprop.c
+++ b/gcc/tree-ssa-forwprop.c
@@ -2479,7 +2479,10 @@ simplify_vector_constructor (gimple_stmt_iterator *gsi)
tree src_type = TREE_TYPE (orig[0]);
if (!useless_type_conversion_p (type, src_type))
{
- gcc_assert (!targetm.compatible_vector_types_p (type, src_type));
+ gcc_assert (known_eq (TYPE_VECTOR_SUBPARTS (type),
+ TYPE_VECTOR_SUBPARTS (src_type))
+ && useless_type_conversion_p (TREE_TYPE (type),
+ TREE_TYPE (src_type)));
tree rhs = build1 (VIEW_CONVERT_EXPR, type, orig[0]);
orig[0] = make_ssa_name (type);
gassign *assign = gimple_build_assign (orig[0], rhs);
@@ -2611,7 +2614,10 @@ simplify_vector_constructor (gimple_stmt_iterator *gsi)
res = gimple_build (&stmts, conv_code, type, res);
else if (!useless_type_conversion_p (type, TREE_TYPE (res)))
{
- gcc_assert (!targetm.compatible_vector_types_p (type, perm_type));
+ gcc_assert (known_eq (TYPE_VECTOR_SUBPARTS (type),
+ TYPE_VECTOR_SUBPARTS (perm_type))
+ && useless_type_conversion_p (TREE_TYPE (type),
+ TREE_TYPE (perm_type)));
res = gimple_build (&stmts, VIEW_CONVERT_EXPR, type, res);
}
/* Blend in the actual constant. */