public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-9689] tree-optimization/101636 - CTOR vectorization ICE
@ 2022-03-23 14:08 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2022-03-23 14:08 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:893cb28a22f86281ca9ce1e045da7b8840ceb121
commit r11-9689-g893cb28a22f86281ca9ce1e045da7b8840ceb121
Author: Richard Biener <rguenther@suse.de>
Date: Wed Feb 23 11:15:38 2022 +0100
tree-optimization/101636 - CTOR vectorization ICE
The following fixes an ICE when vectorizing the defs of a CTOR
results in a different vector type than expected. That can happen
with AARCH64 SVE and a fixed vector length as noted in r10-5979
and on x86 with AVX512 mask CTORs and trying to re-vectorize
using SSE as shown in this bug.
The fix is simply to reject the vectorization when it didn't
produce the desired type.
2022-02-23 Richard Biener <rguenther@suse.de>
PR tree-optimization/101636
PR tree-optimization/104782
* tree-vect-slp.c (vect_slp_analyze_operations): Make sure
the CTOR is vectorized with an expected type.
* c-c++-common/torture/pr101636.c: Likewise.
* gcc.dg/vect/pr104782.c: New testcase.
Diff:
---
gcc/testsuite/c-c++-common/torture/pr101636.c | 30 +++++++++++++++++++++++++++
gcc/testsuite/gcc.dg/vect/pr104782.c | 18 ++++++++++++++++
gcc/tree-vect-slp.c | 8 ++++++-
3 files changed, 55 insertions(+), 1 deletion(-)
diff --git a/gcc/testsuite/c-c++-common/torture/pr101636.c b/gcc/testsuite/c-c++-common/torture/pr101636.c
new file mode 100644
index 00000000000..aedaa1fdcae
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/torture/pr101636.c
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-ftree-vectorize -fno-vect-cost-model" } */
+/* { dg-additional-options "-mavx512f" { target x86_64-*-* i?86-*-* } } */
+
+static inline int
+foo (int y, int a)
+{
+ return (y && a) ? a : 0;
+}
+
+void
+bar (int *__restrict a, int *__restrict d, int *__restrict e, int i)
+{
+ while (i < 1)
+ {
+ e[8] = e[7] = e[6] = e[5] = e[4] = e[3] = e[2] = e[1] = e[0]
+ = foo (d[8], a[8]);
+ e[9] = foo (d[9], a[9]);
+ e[10] = foo (d[0], a[0]);
+ e[11] = foo (d[1], a[1]);
+ e[12] = foo (d[12], a[12]);
+ e[13] = foo (d[13], a[13]);
+ e[14] = foo (d[4], a[4]);
+ e[15] = foo (d[15], a[15]);
+
+ a += 16;
+ e += 1;
+ i += 1;
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/vect/pr104782.c b/gcc/testsuite/gcc.dg/vect/pr104782.c
new file mode 100644
index 00000000000..7b8ca6ca25b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr104782.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-O3" } */
+/* { dg-additional-options "-march=armv8.2-a+sve -msve-vector-bits=128" { target aarch64-*-* } } */
+
+int a, b, c;
+static int d;
+short *q;
+void f() {
+ int *p = &d;
+ b = 9;
+ for (b = 9; b; b--) {
+ a = 2;
+ for (c = 2; c <= 9; c++) {
+ for (int i = 0; i < 3; i++)
+ *p |= (*q)++;
+ }
+ }
+}
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index 01d272df45f..7289656db0f 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -4192,7 +4192,13 @@ vect_slp_analyze_operations (vec_info *vinfo)
SLP tree root. */
|| (SLP_INSTANCE_ROOT_STMT (instance)
&& (SLP_TREE_DEF_TYPE (SLP_INSTANCE_TREE (instance))
- != vect_internal_def)))
+ != vect_internal_def
+ /* Make sure we vectorized with the expected type. */
+ || !useless_type_conversion_p
+ (TREE_TYPE (TREE_TYPE (gimple_assign_rhs1
+ (instance->root_stmt->stmt))),
+ TREE_TYPE (SLP_TREE_VECTYPE
+ (SLP_INSTANCE_TREE (instance)))))))
{
slp_tree node = SLP_INSTANCE_TREE (instance);
stmt_vec_info stmt_info = SLP_TREE_SCALAR_STMTS (node)[0];
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-03-23 14:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-23 14:08 [gcc r11-9689] tree-optimization/101636 - CTOR vectorization ICE Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).