When parsing a _Literal expression, c_parser_gimple_postfix_expression
previously called TYPE_VECTOR_SUBPARTS (type).to_constant () to
determine the number of elements for which to allocate space in a
vector. That did not work for vectors of vector-length agnostic
type, such as the svuint8_t type defined by <arm_sve.h>.
gcc/c/ChangeLog:
PR c/128606
* gimple-parser.cc (c_parser_gimple_postfix_expression):
Substitute a call to constant_lower_bound () in place of
to_constant ().
gcc/testsuite/ChangeLog:
PR c/128606
* gcc.target/aarch64/sve/pr128606_1.c,
gcc.target/aarch64/sve/pr128606_10.c,
gcc.target/aarch64/sve/pr128606_11.c,
gcc.target/aarch64/sve/pr128606_2.c,
gcc.target/aarch64/sve/pr128606_3.c,
gcc.target/aarch64/sve/pr128606_4.c,
gcc.target/aarch64/sve/pr128606_5.c,
gcc.target/aarch64/sve/pr128606_6.c,
gcc.target/aarch64/sve/pr128606_7.c,
gcc.target/aarch64/sve/pr128606_8.c,
gcc.target/aarch64/sve/pr128606_9.c: New tests.
* gcc.target/aarch64/sve/pr128606_primes.h: Shared test code.
---
gcc/c/gimple-parser.cc | 3 +-
.../gcc.target/aarch64/sve/pr128606_1.c | 6 ++
.../gcc.target/aarch64/sve/pr128606_10.c | 6 ++
.../gcc.target/aarch64/sve/pr128606_11.c | 6 ++
.../gcc.target/aarch64/sve/pr128606_2.c | 6 ++
.../gcc.target/aarch64/sve/pr128606_3.c | 6 ++
.../gcc.target/aarch64/sve/pr128606_4.c | 6 ++
.../gcc.target/aarch64/sve/pr128606_5.c | 6 ++
.../gcc.target/aarch64/sve/pr128606_6.c | 6 ++
.../gcc.target/aarch64/sve/pr128606_7.c | 6 ++
.../gcc.target/aarch64/sve/pr128606_8.c | 6 ++
.../gcc.target/aarch64/sve/pr128606_9.c | 6 ++
.../gcc.target/aarch64/sve/pr128606_primes.h | 64 +++++++++++++++++++
13 files changed, 132 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.target/aarch64/sve/pr128606_1.c
create mode 100644 gcc/testsuite/gcc.target/aarch64/sve/pr128606_10.c
create mode 100644 gcc/testsuite/gcc.target/aarch64/sve/pr128606_11.c
create mode 100644 gcc/testsuite/gcc.target/aarch64/sve/pr128606_2.c
create mode 100644 gcc/testsuite/gcc.target/aarch64/sve/pr128606_3.c
create mode 100644 gcc/testsuite/gcc.target/aarch64/sve/pr128606_4.c
create mode 100644 gcc/testsuite/gcc.target/aarch64/sve/pr128606_5.c
create mode 100644 gcc/testsuite/gcc.target/aarch64/sve/pr128606_6.c
create mode 100644 gcc/testsuite/gcc.target/aarch64/sve/pr128606_7.c
create mode 100644 gcc/testsuite/gcc.target/aarch64/sve/pr128606_8.c
create mode 100644 gcc/testsuite/gcc.target/aarch64/sve/pr128606_9.c
create mode 100644 gcc/testsuite/gcc.target/aarch64/sve/pr128606_primes.h
OK for trunk?
diff --git a/gcc/c/gimple-parser.cc b/gcc/c/gimple-parser.cc
index 0e0c8ba673b..874f9d7a3b2 100644
--- a/gcc/c/gimple-parser.cc
+++ b/gcc/c/gimple-parser.cc
@@ -1837,7 +1837,8 @@ c_parser_gimple_postfix_expression (gimple_parser
&parser, tree ret_type)
if (VECTOR_TYPE_P (type)
&& !c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
{
- vec_alloc (v, TYPE_VECTOR_SUBPARTS (type).to_constant ());
+ vec_alloc (v, constant_lower_bound (
+ TYPE_VECTOR_SUBPARTS (type)));
do
{
tree val
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/pr128606_1.c
b/gcc/testsuite/gcc.target/aarch64/sve/pr128606_1.c
new file mode 100644
index 00000000000..a7b529216e3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve/pr128606_1.c
@@ -0,0 +1,6 @@
+/* { dg-options "-fgimple -fdump-tree-gimple -msve-vector-bits=128" } */
+/* { dg-final { scan-tree-dump {v = \{ 2, 3, 5, 7, 11, 13, 17, 19, (0, ){7}0
\};} "gimple" } } */
+
+#define ELEM_TYPE uint8_t
+#define NUM_PRIMES 8
+#include "pr128606_primes.h"
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/pr128606_10.c
b/gcc/testsuite/gcc.target/aarch64/sve/pr128606_10.c
new file mode 100644
index 00000000000..61ca235015a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve/pr128606_10.c
@@ -0,0 +1,6 @@
+/* { dg-options "-fgimple -fdump-tree-gimple -msve-vector-bits=512" } */
+/* { dg-final { scan-tree-dump {v = \{ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31,
37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109,
113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197,
199, 211, 223, 227, 229, 233, 239, 241, 251, 241, 239, 233, 229, 227, 223, 211,
199, 197, 193 \};} "gimple" } } */
+
+#define ELEM_TYPE uint8_t
+#define NUM_PRIMES 64
+#include "pr128606_primes.h"
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/pr128606_11.c
b/gcc/testsuite/gcc.target/aarch64/sve/pr128606_11.c
new file mode 100644
index 00000000000..f336815f131
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve/pr128606_11.c
@@ -0,0 +1,6 @@
+/* { dg-options "-fgimple -fdump-tree-gimple -msve-vector-bits=scalable" } */
+/* { dg-final { scan-tree-dump {v = \{ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31,
37, 41, 43, 47, 53, (0, ){16}\.\.\. \};} "gimple" } } */
+
+#define ELEM_TYPE uint8_t
+#define NUM_PRIMES 16
+#include "pr128606_primes.h"
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/pr128606_2.c
b/gcc/testsuite/gcc.target/aarch64/sve/pr128606_2.c
new file mode 100644
index 00000000000..0863e1660bb
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve/pr128606_2.c
@@ -0,0 +1,6 @@
+/* { dg-options "-fgimple -fdump-tree-gimple -msve-vector-bits=256" } */
+/* { dg-final { scan-tree-dump {v = \{ 2, 3, 5, 7, 11, 13, 17, 19, (0, ){23}0
\};} "gimple" } } */
+
+#define ELEM_TYPE uint8_t
+#define NUM_PRIMES 8
+#include "pr128606_primes.h"
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/pr128606_3.c
b/gcc/testsuite/gcc.target/aarch64/sve/pr128606_3.c
new file mode 100644
index 00000000000..ce1a8ccc9d7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve/pr128606_3.c
@@ -0,0 +1,6 @@
+/* { dg-options "-fgimple -fdump-tree-gimple -msve-vector-bits=512" } */
+/* { dg-final { scan-tree-dump {v = \{ 2, 3, 5, 7, 11, 13, 17, 19, (0, ){55}0
\};} "gimple" } } */
+
+#define ELEM_TYPE uint8_t
+#define NUM_PRIMES 8
+#include "pr128606_primes.h"
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/pr128606_4.c
b/gcc/testsuite/gcc.target/aarch64/sve/pr128606_4.c
new file mode 100644
index 00000000000..f2992dc821e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve/pr128606_4.c
@@ -0,0 +1,6 @@
+/* { dg-options "-fgimple -fdump-tree-gimple -msve-vector-bits=scalable" } */
+/* { dg-final { scan-tree-dump {v = \{ 2, 3, 5, 7, 11, 13, 17, 19, (0,
){8}\.\.\. \};} "gimple" } } */
+
+#define ELEM_TYPE uint8_t
+#define NUM_PRIMES 8
+#include "pr128606_primes.h"
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/pr128606_5.c
b/gcc/testsuite/gcc.target/aarch64/sve/pr128606_5.c
new file mode 100644
index 00000000000..f247eb18d1a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve/pr128606_5.c
@@ -0,0 +1,6 @@
+/* { dg-options "-fgimple -fdump-tree-gimple -msve-vector-bits=128" } */
+/* { dg-final { scan-tree-dump {v = \{ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31,
37, 41, 43, 47, 53 \};} "gimple" } } */
+
+#define ELEM_TYPE uint8_t
+#define NUM_PRIMES 16
+#include "pr128606_primes.h"
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/pr128606_6.c
b/gcc/testsuite/gcc.target/aarch64/sve/pr128606_6.c
new file mode 100644
index 00000000000..7282437db13
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve/pr128606_6.c
@@ -0,0 +1,6 @@
+/* { dg-options "-fgimple -fdump-tree-gimple -msve-vector-bits=256" } */
+/* { dg-final { scan-tree-dump {v = \{ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31,
37, 41, 43, 47, 53 \};} "gimple" } } */
+
+#define ELEM_TYPE uint16_t
+#define NUM_PRIMES 16
+#include "pr128606_primes.h"
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/pr128606_7.c
b/gcc/testsuite/gcc.target/aarch64/sve/pr128606_7.c
new file mode 100644
index 00000000000..159ea89c583
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve/pr128606_7.c
@@ -0,0 +1,6 @@
+/* { dg-options "-fgimple -fdump-tree-gimple -msve-vector-bits=512" } */
+/* { dg-final { scan-tree-dump {v = \{ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31,
37, 41, 43, 47, 53 \};} "gimple" } } */
+
+#define ELEM_TYPE uint32_t
+#define NUM_PRIMES 16
+#include "pr128606_primes.h"
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/pr128606_8.c
b/gcc/testsuite/gcc.target/aarch64/sve/pr128606_8.c
new file mode 100644
index 00000000000..5eb81baaf06
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve/pr128606_8.c
@@ -0,0 +1,6 @@
+/* { dg-options "-fgimple -fdump-tree-gimple -msve-vector-bits=scalable" } */
+/* { dg-final { scan-tree-dump {v = \{ 2, 3, 5, 7, 11, 13, 17, 19, (0,
){8}\.\.\. \};} "gimple" } } */
+
+#define ELEM_TYPE uint16_t
+#define NUM_PRIMES 8
+#include "pr128606_primes.h"
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/pr128606_9.c
b/gcc/testsuite/gcc.target/aarch64/sve/pr128606_9.c
new file mode 100644
index 00000000000..4a64b097ca0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve/pr128606_9.c
@@ -0,0 +1,6 @@
+/* { dg-options "-fgimple -fdump-tree-gimple -msve-vector-bits=256" } */
+/* { dg-final { scan-tree-dump {v = \{ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31,
37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109,
113, 127, 131 \};} "gimple" } } */
+
+#define ELEM_TYPE uint8_t
+#define NUM_PRIMES 32
+#include "pr128606_primes.h"
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/pr128606_primes.h
b/gcc/testsuite/gcc.target/aarch64/sve/pr128606_primes.h
new file mode 100644
index 00000000000..5f11d05cdb0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve/pr128606_primes.h
@@ -0,0 +1,64 @@
+
+#ifndef ELEM_TYPE
+#error "No element type defined"
+#endif
+
+#include <arm_sve.h>
+
+#define JOIN2(A, B) A##B
+#define JOIN(A, B) JOIN2 (A, B)
+#define VEC_TYPE JOIN (sv, ELEM_TYPE)
+#define LIT _Literal (typeof ((ELEM_TYPE) __COUNTER__))
+
+#if (NUM_PRIMES < 1) || (NUM_PRIMES > 64) || (NUM_PRIMES != (NUM_PRIMES &
~(NUM_PRIMES - 1)))
+#error "Unsupported value of NUM_PRIMES"
+#endif
+
+enum
+{
+ start = __COUNTER__
+};
+
+VEC_TYPE
+__GIMPLE (startwith ("expand")) foo (void)
+{
+ VEC_TYPE v;
+
+ v = _Literal (VEC_TYPE){LIT 2
+#if NUM_PRIMES > 1
+ , LIT 3
+#endif
+#if NUM_PRIMES > 2
+
+ , LIT 5, LIT 7
+#endif
+#if NUM_PRIMES > 4
+
+ , LIT 11, LIT 13, LIT 17, LIT 19
+#endif
+#if NUM_PRIMES > 8
+ , LIT 23, LIT 29, LIT 31, LIT 37, LIT 41, LIT 43, LIT
47, LIT 53
+#endif
+#if NUM_PRIMES > 16
+ , LIT 59, LIT 61, LIT 67, LIT 71, LIT 73, LIT 79, LIT
83, LIT 89,
+ LIT 97, LIT 101, LIT 103, LIT 107, LIT 109, LIT
113, LIT 127, LIT 131
+#endif
+#if NUM_PRIMES > 32
+ , LIT 137, LIT 139, LIT 149, LIT 151, LIT 157, LIT
163, LIT 167, LIT 173,
+ LIT 179, LIT 181, LIT 191, LIT 193, LIT 197, LIT
199, LIT 211, LIT 223,
+ LIT 227, LIT 229, LIT 233, LIT 239, LIT 241, LIT
251, LIT 241, LIT 239,
+ LIT 233, LIT 229, LIT 227, LIT 223, LIT 211, LIT
199, LIT 197, LIT 193
+#endif
+ };
+
+ return v;
+}
+
+_Static_assert (__COUNTER__ - 1 - start == NUM_PRIMES,
+ "Incorrect number of initialisers");
+
+#undef JOIN
+#undef JOIN2
+#undef LIT
+#undef ELEM_TYPE
+#undef VEC_TYPE
--
2.43.0