diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2019-11-08 08:35:55 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2019-11-08 08:35:55 +0000 |
commit | f486280c53be53136f0bb9b578f43dc6c9c5acea (patch) | |
tree | 889dee82b7f1a9c7ac625d3b7871fc3808d4e79a | |
parent | 09eb042a8a8ee16e8f23085a175be25c8ef68820 (diff) | |
download | gcc-f486280c53be53136f0bb9b578f43dc6c9c5acea.zip gcc-f486280c53be53136f0bb9b578f43dc6c9c5acea.tar.gz gcc-f486280c53be53136f0bb9b578f43dc6c9c5acea.tar.bz2 |
[C] Opt out of GNU vector extensions for built-in SVE types
The AArch64 port defines built-in SVE types at start-up under names
like __SVInt8_t. These types are represented in the front end and
gimple as normal VECTOR_TYPEs and are code-generated as normal vectors.
However, we'd like to stop the frontends from treating them in the
same way as GNU-style ("vector_size") vectors, for several reasons:
(1) We allowed the GNU vector extensions to be mixed with Advanced SIMD
vector types and it ended up causing a lot of confusion on big-endian
targets. Although SVE handles big-endian vectors differently from
Advanced SIMD, there are still potential surprises; see the block
comment near the head of aarch64-sve.md for details.
(2) One of the SVE vectors is a packed one-bit-per-element boolean vector.
That isn't a combination the GNU vector extensions have supported
before. E.g. it means that vectors can no longer decompose to
arrays for indexing, and that not all elements are individually
addressable. It also makes it less clear which order the initialiser
should be in (lsb first, or bitfield ordering?). We could define
all that of course, but it seems a bit weird to go to the effort
for this case when, given all the other reasons, we don't want the
extensions anyway.
(3) The GNU vector extensions only provide full-vector operations,
which is a very artifical limitation on a predicated architecture
like SVE.
(4) The set of operations provided by the GNU vector extensions is
relatively small, whereas the SVE intrinsics provide many more.
(5) It makes it easier to ensure that (with default options) code is
portable between compilers without the GNU vector extensions having
to become an official part of the SVE intrinsics spec.
(6) The length of the SVE types is usually not fixed at compile time,
whereas the GNU vector extension is geared around fixed-length
vectors.
It's possible to specify the length of an SVE vector using the
command-line option -msve-vector-bits=N, but in principle it should
be possible to have functions compiled for different N in the same
translation unit. This isn't supported yet but would be very useful
for implementing ifuncs. Once mixing lengths in a translation unit
is supported, the SVE types should represent the same type throughout
the translation unit, just as GNU vector types do.
However, when -msve-vector-bits=N is in effect, we do allow conversions
between explicit GNU vector types of N bits and the corresponding SVE
types. This doesn't undermine the intent of (5) because in this case
the use of GNU vector types is explicit and intentional. It also doesn't
undermine the intent of (6) because converting between the types is just
a conditionally-supported operation. In other words, the types still
represent the same types throughout the translation unit, it's just that
conversions between them are valid in cases where a certain precondition
is known to hold. It's similar to the way that the SVE vector types are
defined throughout the translation unit but can only be used in functions
for which SVE is enabled.
The patch adds a new flag to tree_type_common to select this behaviour.
(We currently have 17 bits free.) To avoid making the flag too specific
to vectors, I called it TYPE_INDIVISIBLE_P, to mean that the frontend
should not allow the components of the type to be accessed directly.
This could perhaps be useful in future for hiding the fact that a
type is an array, or for hiding the fields of a record or union.
The actual frontend changes are very simple, mostly just replacing
VECTOR_TYPE_P with gnu_vector_type_p in selected places.
One interesting case is:
/* Need to convert condition operand into a vector mask. */
if (VECTOR_TYPE_P (TREE_TYPE (ifexp)))
{
tree vectype = TREE_TYPE (ifexp);
tree elem_type = TREE_TYPE (vectype);
tree zero = build_int_cst (elem_type, 0);
tree zero_vec = build_vector_from_val (vectype, zero);
tree cmp_type = build_same_sized_truth_vector_type (vectype);
ifexp = build2 (NE_EXPR, cmp_type, ifexp, zero_vec);
}
in build_conditional_expr. This appears to be trying to support
elementwise conditions like "vec1 ? vec2 : vec3", which is something
the C++ frontend supports. However, this code can never trigger AFAICT,
because "vec1" does not survive c_objc_common_truthvalue_conversion:
case VECTOR_TYPE:
error_at (location, "used vector type where scalar is required");
return error_mark_node;
Even if it did, the operation should be a VEC_COND_EXPR rather
than a COND_EXPR.
I've therefore left that condition as-is, but added tests for the
"vec1 ? vec2 : vec3" case to make sure that we don't accidentally
allow it for SVE vectors in future.
2019-11-08 Richard Sandiford <richard.sandiford@arm.com>
gcc/
* tree-core.h (tree_type_common::indivisible_p): New member variable.
* tree.h (TYPE_INDIVISIBLE_P): New macro.
* config/aarch64/aarch64-sve-builtins.cc (register_builtin_types):
Treat the vector types as indivisible.
gcc/c-family/
* c-common.h (gnu_vector_type_p): New function.
* c-common.c (c_build_vec_perm_expr): Require __builtin_shuffle
vectors to satisfy gnu_vector_type_p.
(c_build_vec_convert): Likewise __builtin_convertvector.
(convert_vector_to_array_for_subscript): Likewise when applying
implicit vector to array conversion.
(scalar_to_vector): Likewise when converting vector-scalar
operations to vector-vector operations.
gcc/c/
* c-convert.c (convert): Only handle vector conversions if one of
the types satisfies gnu_vector_type_p or if -flax-vector-conversions
allows it.
* c-typeck.c (build_array_ref): Only allow vector indexing if the
vectors satisfy gnu_vector_type_p.
(build_unary_op): Only allow unary operators to be applied to
vectors if they satisfy gnu_vector_type_p.
(digest_init): Only allow by-element initialization of vectors
if they satisfy gnu_vector_type_p.
(really_start_incremental_init): Likewise.
(push_init_level): Likewise.
(pop_init_level): Likewise.
(process_init_element): Likewise.
(build_binary_op): Only allow binary operators to be applied to
vectors if they satisfy gnu_vector_type_p.
gcc/testsuite/
* gcc.target/aarch64/sve/acle/general-c/gnu_vectors_1.c: New test.
* gcc.target/aarch64/sve/acle/general-c/gnu_vectors_2.c: Likewise.
From-SVN: r277950
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/c-family/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/c-family/c-common.c | 21 | ||||
-rw-r--r-- | gcc/c-family/c-common.h | 10 | ||||
-rw-r--r-- | gcc/c/ChangeLog | 18 | ||||
-rw-r--r-- | gcc/c/c-convert.c | 16 | ||||
-rw-r--r-- | gcc/c/c-typeck.c | 71 | ||||
-rw-r--r-- | gcc/config/aarch64/aarch64-sve-builtins.cc | 1 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/gnu_vectors_1.c | 415 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/gnu_vectors_2.c | 415 | ||||
-rw-r--r-- | gcc/tree-core.h | 3 | ||||
-rw-r--r-- | gcc/tree.h | 5 |
13 files changed, 957 insertions, 41 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ab690af..f4829fd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,12 @@ 2019-11-08 Richard Sandiford <richard.sandiford@arm.com> + * tree-core.h (tree_type_common::indivisible_p): New member variable. + * tree.h (TYPE_INDIVISIBLE_P): New macro. + * config/aarch64/aarch64-sve-builtins.cc (register_builtin_types): + Treat the vector types as indivisible. + +2019-11-08 Richard Sandiford <richard.sandiford@arm.com> + * optabs.def (gather_load_optab, mask_gather_load_optab) (scatter_store_optab, mask_scatter_store_optab): Turn into conversion optabs, with the offset mode given explicitly. diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index d3e328f..c0efe90 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,14 @@ +2019-11-08 Richard Sandiford <richard.sandiford@arm.com> + + * c-common.h (gnu_vector_type_p): New function. + * c-common.c (c_build_vec_perm_expr): Require __builtin_shuffle + vectors to satisfy gnu_vector_type_p. + (c_build_vec_convert): Likewise __builtin_convertvector. + (convert_vector_to_array_for_subscript): Likewise when applying + implicit vector to array conversion. + (scalar_to_vector): Likewise when converting vector-scalar + operations to vector-vector operations. + 2019-11-08 Joseph Myers <joseph@codesourcery.com> * c.opt (Wold-style-definition): Initialize to -1. diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 743ef04..4881199 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -1011,7 +1011,8 @@ c_build_vec_perm_expr (location_t loc, tree v0, tree v1, tree mask, || mask == error_mark_node) return error_mark_node; - if (!VECTOR_INTEGER_TYPE_P (TREE_TYPE (mask))) + if (!gnu_vector_type_p (TREE_TYPE (mask)) + || !VECTOR_INTEGER_TYPE_P (TREE_TYPE (mask))) { if (complain) error_at (loc, "%<__builtin_shuffle%> last argument must " @@ -1019,8 +1020,8 @@ c_build_vec_perm_expr (location_t loc, tree v0, tree v1, tree mask, return error_mark_node; } - if (!VECTOR_TYPE_P (TREE_TYPE (v0)) - || !VECTOR_TYPE_P (TREE_TYPE (v1))) + if (!gnu_vector_type_p (TREE_TYPE (v0)) + || !gnu_vector_type_p (TREE_TYPE (v1))) { if (complain) error_at (loc, "%<__builtin_shuffle%> arguments must be vectors"); @@ -1095,8 +1096,9 @@ c_build_vec_convert (location_t loc1, tree expr, location_t loc2, tree type, if (error_operand_p (expr)) return error_mark_node; - if (!VECTOR_INTEGER_TYPE_P (TREE_TYPE (expr)) - && !VECTOR_FLOAT_TYPE_P (TREE_TYPE (expr))) + if (!gnu_vector_type_p (TREE_TYPE (expr)) + || (!VECTOR_INTEGER_TYPE_P (TREE_TYPE (expr)) + && !VECTOR_FLOAT_TYPE_P (TREE_TYPE (expr)))) { if (complain) error_at (loc1, "%<__builtin_convertvector%> first argument must " @@ -1104,7 +1106,8 @@ c_build_vec_convert (location_t loc1, tree expr, location_t loc2, tree type, return error_mark_node; } - if (!VECTOR_INTEGER_TYPE_P (type) && !VECTOR_FLOAT_TYPE_P (type)) + if (!gnu_vector_type_p (type) + || (!VECTOR_INTEGER_TYPE_P (type) && !VECTOR_FLOAT_TYPE_P (type))) { if (complain) error_at (loc2, "%<__builtin_convertvector%> second argument must " @@ -8024,7 +8027,7 @@ convert_vector_to_array_for_subscript (location_t loc, tree *vecp, tree index) { bool ret = false; - if (VECTOR_TYPE_P (TREE_TYPE (*vecp))) + if (gnu_vector_type_p (TREE_TYPE (*vecp))) { tree type = TREE_TYPE (*vecp); @@ -8060,7 +8063,7 @@ scalar_to_vector (location_t loc, enum tree_code code, tree op0, tree op1, bool integer_only_op = false; enum stv_conv ret = stv_firstarg; - gcc_assert (VECTOR_TYPE_P (type0) || VECTOR_TYPE_P (type1)); + gcc_assert (gnu_vector_type_p (type0) || gnu_vector_type_p (type1)); switch (code) { /* Most GENERIC binary expressions require homogeneous arguments. @@ -8111,7 +8114,7 @@ scalar_to_vector (location_t loc, enum tree_code code, tree op0, tree op1, case LT_EXPR: case GT_EXPR: /* What about UNLT_EXPR? */ - if (VECTOR_TYPE_P (type0)) + if (gnu_vector_type_p (type0)) { ret = stv_secondarg; std::swap (type0, type1); diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index bae7644..80a8c9f 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -757,6 +757,16 @@ extern bool done_lexing; #define C_TYPE_OBJECT_OR_INCOMPLETE_P(type) \ (!C_TYPE_FUNCTION_P (type)) +/* Return true if TYPE is a vector type that should be subject to the GNU + vector extensions (as opposed to a vector type that is used only for + the purposes of defining target-specific built-in functions). */ + +inline bool +gnu_vector_type_p (const_tree type) +{ + return TREE_CODE (type) == VECTOR_TYPE && !TYPE_INDIVISIBLE_P (type); +} + struct visibility_flags { unsigned inpragma : 1; /* True when in #pragma GCC visibility. */ diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index f1d73e4..8cea3f5 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,21 @@ +2019-11-08 Richard Sandiford <richard.sandiford@arm.com> + + * c-convert.c (convert): Only handle vector conversions if one of + the types satisfies gnu_vector_type_p or if -flax-vector-conversions + allows it. + * c-typeck.c (build_array_ref): Only allow vector indexing if the + vectors satisfy gnu_vector_type_p. + (build_unary_op): Only allow unary operators to be applied to + vectors if they satisfy gnu_vector_type_p. + (digest_init): Only allow by-element initialization of vectors + if they satisfy gnu_vector_type_p. + (really_start_incremental_init): Likewise. + (push_init_level): Likewise. + (pop_init_level): Likewise. + (process_init_element): Likewise. + (build_binary_op): Only allow binary operators to be applied to + vectors if they satisfy gnu_vector_type_p. + 2019-11-08 Joseph Myers <joseph@codesourcery.com> * c-decl.c (grokparms): Convert () in a function definition to diff --git a/gcc/c/c-convert.c b/gcc/c/c-convert.c index f0f8460..21b127d 100644 --- a/gcc/c/c-convert.c +++ b/gcc/c/c-convert.c @@ -147,8 +147,20 @@ convert (tree type, tree expr) goto maybe_fold; case VECTOR_TYPE: - ret = convert_to_vector (type, e); - goto maybe_fold; + if (gnu_vector_type_p (type) + || gnu_vector_type_p (TREE_TYPE (e)) + /* Allow conversions between compatible non-GNU vector types + when -flax-vector-conversions is passed. The whole purpose + of the option is to bend the normal type rules and accept + nonconforming code. */ + || (flag_lax_vector_conversions + && VECTOR_TYPE_P (TREE_TYPE (e)) + && vector_types_convertible_p (type, TREE_TYPE (e), false))) + { + ret = convert_to_vector (type, e); + goto maybe_fold; + } + break; case RECORD_TYPE: case UNION_TYPE: diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index c733950..793d10e 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -2610,7 +2610,7 @@ build_array_ref (location_t loc, tree array, tree index) if (TREE_CODE (TREE_TYPE (array)) != ARRAY_TYPE && TREE_CODE (TREE_TYPE (array)) != POINTER_TYPE /* Allow vector[index] but not index[vector]. */ - && !VECTOR_TYPE_P (TREE_TYPE (array))) + && !gnu_vector_type_p (TREE_TYPE (array))) { if (TREE_CODE (TREE_TYPE (index)) != ARRAY_TYPE && TREE_CODE (TREE_TYPE (index)) != POINTER_TYPE) @@ -4360,7 +4360,7 @@ build_unary_op (location_t location, enum tree_code code, tree xarg, associativity, but won't generate any code. */ if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE || typecode == FIXED_POINT_TYPE || typecode == COMPLEX_TYPE - || typecode == VECTOR_TYPE)) + || gnu_vector_type_p (TREE_TYPE (arg)))) { error_at (location, "wrong type argument to unary plus"); return error_mark_node; @@ -4373,7 +4373,7 @@ build_unary_op (location_t location, enum tree_code code, tree xarg, case NEGATE_EXPR: if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE || typecode == FIXED_POINT_TYPE || typecode == COMPLEX_TYPE - || typecode == VECTOR_TYPE)) + || gnu_vector_type_p (TREE_TYPE (arg)))) { error_at (location, "wrong type argument to unary minus"); return error_mark_node; @@ -4385,7 +4385,7 @@ build_unary_op (location_t location, enum tree_code code, tree xarg, case BIT_NOT_EXPR: /* ~ works on integer types and non float vectors. */ if (typecode == INTEGER_TYPE - || (typecode == VECTOR_TYPE + || (gnu_vector_type_p (TREE_TYPE (arg)) && !VECTOR_FLOAT_TYPE_P (TREE_TYPE (arg)))) { tree e = arg; @@ -4571,7 +4571,8 @@ build_unary_op (location_t location, enum tree_code code, tree xarg, if (typecode != POINTER_TYPE && typecode != FIXED_POINT_TYPE && typecode != INTEGER_TYPE && typecode != REAL_TYPE - && typecode != COMPLEX_TYPE && typecode != VECTOR_TYPE) + && typecode != COMPLEX_TYPE + && !gnu_vector_type_p (TREE_TYPE (arg))) { if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR) error_at (location, "wrong type argument to increment"); @@ -7858,7 +7859,7 @@ digest_init (location_t init_loc, tree type, tree init, tree origtype, TYPE_MAIN_VARIANT (type)) || (code == ARRAY_TYPE && comptypes (TREE_TYPE (inside_init), type)) - || (code == VECTOR_TYPE + || (gnu_vector_type_p (type) && comptypes (TREE_TYPE (inside_init), type)) || (code == POINTER_TYPE && TREE_CODE (TREE_TYPE (inside_init)) == ARRAY_TYPE @@ -8356,7 +8357,7 @@ really_start_incremental_init (tree type) constructor_unfilled_index = constructor_index; } - else if (VECTOR_TYPE_P (constructor_type)) + else if (gnu_vector_type_p (constructor_type)) { /* Vectors are like simple fixed-size arrays. */ constructor_max_index = @@ -8530,7 +8531,7 @@ push_init_level (location_t loc, int implicit, constructor_unfilled_fields = constructor_fields; constructor_bit_index = bitsize_zero_node; } - else if (VECTOR_TYPE_P (constructor_type)) + else if (gnu_vector_type_p (constructor_type)) { /* Vectors are like simple fixed-size arrays. */ constructor_max_index = @@ -8719,7 +8720,7 @@ pop_init_level (location_t loc, int implicit, ; else if (!RECORD_OR_UNION_TYPE_P (constructor_type) && TREE_CODE (constructor_type) != ARRAY_TYPE - && !VECTOR_TYPE_P (constructor_type)) + && !gnu_vector_type_p (constructor_type)) { /* A nonincremental scalar initializer--just return the element, after verifying there is just one. */ @@ -9945,7 +9946,7 @@ process_init_element (location_t loc, struct c_expr value, bool implicit, last_init_list_comma), true, braced_init_obstack); else if ((TREE_CODE (constructor_type) == ARRAY_TYPE - || VECTOR_TYPE_P (constructor_type)) + || gnu_vector_type_p (constructor_type)) && constructor_max_index && tree_int_cst_lt (constructor_max_index, constructor_index)) @@ -10046,7 +10047,8 @@ process_init_element (location_t loc, struct c_expr value, bool implicit, && value.value != error_mark_node && TYPE_MAIN_VARIANT (TREE_TYPE (value.value)) != fieldtype && (fieldcode == RECORD_TYPE || fieldcode == ARRAY_TYPE - || fieldcode == UNION_TYPE || fieldcode == VECTOR_TYPE)) + || fieldcode == UNION_TYPE + || gnu_vector_type_p (fieldtype))) { push_init_level (loc, 1, braced_init_obstack); continue; @@ -10137,7 +10139,8 @@ process_init_element (location_t loc, struct c_expr value, bool implicit, && value.value != error_mark_node && TYPE_MAIN_VARIANT (TREE_TYPE (value.value)) != fieldtype && (fieldcode == RECORD_TYPE || fieldcode == ARRAY_TYPE - || fieldcode == UNION_TYPE || fieldcode == VECTOR_TYPE)) + || fieldcode == UNION_TYPE + || gnu_vector_type_p (fieldtype))) { push_init_level (loc, 1, braced_init_obstack); continue; @@ -10179,7 +10182,8 @@ process_init_element (location_t loc, struct c_expr value, bool implicit, && value.value != error_mark_node && TYPE_MAIN_VARIANT (TREE_TYPE (value.value)) != elttype && (eltcode == RECORD_TYPE || eltcode == ARRAY_TYPE - || eltcode == UNION_TYPE || eltcode == VECTOR_TYPE)) + || eltcode == UNION_TYPE + || gnu_vector_type_p (elttype))) { push_init_level (loc, 1, braced_init_obstack); continue; @@ -10215,7 +10219,7 @@ process_init_element (location_t loc, struct c_expr value, bool implicit, constructor_unfilled_index. */ constructor_unfilled_index = constructor_index; } - else if (VECTOR_TYPE_P (constructor_type)) + else if (gnu_vector_type_p (constructor_type)) { tree elttype = TYPE_MAIN_VARIANT (TREE_TYPE (constructor_type)); @@ -11559,7 +11563,8 @@ build_binary_op (location_t location, enum tree_code code, /* In case when one of the operands of the binary operation is a vector and another is a scalar -- convert scalar to vector. */ - if ((code0 == VECTOR_TYPE) != (code1 == VECTOR_TYPE)) + if ((gnu_vector_type_p (type0) && code1 != VECTOR_TYPE) + || (gnu_vector_type_p (type1) && code0 != VECTOR_TYPE)) { enum stv_conv convert_flag = scalar_to_vector (location, code, op0, op1, true); @@ -11654,10 +11659,12 @@ build_binary_op (location_t location, enum tree_code code, if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE || code0 == FIXED_POINT_TYPE - || code0 == COMPLEX_TYPE || code0 == VECTOR_TYPE) + || code0 == COMPLEX_TYPE + || gnu_vector_type_p (type0)) && (code1 == INTEGER_TYPE || code1 == REAL_TYPE || code1 == FIXED_POINT_TYPE - || code1 == COMPLEX_TYPE || code1 == VECTOR_TYPE)) + || code1 == COMPLEX_TYPE + || gnu_vector_type_p (type1))) { enum tree_code tcode0 = code0, tcode1 = code1; @@ -11688,8 +11695,8 @@ build_binary_op (location_t location, enum tree_code code, if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE) shorten = -1; /* Allow vector types which are not floating point types. */ - else if (code0 == VECTOR_TYPE - && code1 == VECTOR_TYPE + else if (gnu_vector_type_p (type0) + && gnu_vector_type_p (type1) && !VECTOR_FLOAT_TYPE_P (type0) && !VECTOR_FLOAT_TYPE_P (type1)) common = 1; @@ -11700,7 +11707,8 @@ build_binary_op (location_t location, enum tree_code code, doing_div_or_mod = true; warn_for_div_by_zero (location, op1); - if (code0 == VECTOR_TYPE && code1 == VECTOR_TYPE + if (gnu_vector_type_p (type0) + && gnu_vector_type_p (type1) && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE && TREE_CODE (TREE_TYPE (type1)) == INTEGER_TYPE) common = 1; @@ -11779,7 +11787,8 @@ build_binary_op (location_t location, enum tree_code code, Also set SHORT_SHIFT if shifting rightward. */ case RSHIFT_EXPR: - if (code0 == VECTOR_TYPE && code1 == VECTOR_TYPE + if (gnu_vector_type_p (type0) + && gnu_vector_type_p (type1) && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE && TREE_CODE (TREE_TYPE (type1)) == INTEGER_TYPE && known_eq (TYPE_VECTOR_SUBPARTS (type0), @@ -11789,7 +11798,7 @@ build_binary_op (location_t location, enum tree_code code, converted = 1; } else if ((code0 == INTEGER_TYPE || code0 == FIXED_POINT_TYPE - || (code0 == VECTOR_TYPE + || (gnu_vector_type_p (type0) && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE)) && code1 == INTEGER_TYPE) { @@ -11838,7 +11847,8 @@ build_binary_op (location_t location, enum tree_code code, break; case LSHIFT_EXPR: - if (code0 == VECTOR_TYPE && code1 == VECTOR_TYPE + if (gnu_vector_type_p (type0) + && gnu_vector_type_p (type1) && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE && TREE_CODE (TREE_TYPE (type1)) == INTEGER_TYPE && known_eq (TYPE_VECTOR_SUBPARTS (type0), @@ -11848,7 +11858,7 @@ build_binary_op (location_t location, enum tree_code code, converted = 1; } else if ((code0 == INTEGER_TYPE || code0 == FIXED_POINT_TYPE - || (code0 == VECTOR_TYPE + || (gnu_vector_type_p (type0) && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE)) && code1 == INTEGER_TYPE) { @@ -11907,7 +11917,7 @@ build_binary_op (location_t location, enum tree_code code, case EQ_EXPR: case NE_EXPR: - if (code0 == VECTOR_TYPE && code1 == VECTOR_TYPE) + if (gnu_vector_type_p (type0) && gnu_vector_type_p (type1)) { tree intt; if (!vector_types_compatible_elements_p (type0, type1)) @@ -12075,7 +12085,7 @@ build_binary_op (location_t location, enum tree_code code, case GE_EXPR: case LT_EXPR: case GT_EXPR: - if (code0 == VECTOR_TYPE && code1 == VECTOR_TYPE) + if (gnu_vector_type_p (type0) && gnu_vector_type_p (type1)) { tree intt; if (!vector_types_compatible_elements_p (type0, type1)) @@ -12222,7 +12232,8 @@ build_binary_op (location_t location, enum tree_code code, if (code0 == ERROR_MARK || code1 == ERROR_MARK) return error_mark_node; - if (code0 == VECTOR_TYPE && code1 == VECTOR_TYPE + if (gnu_vector_type_p (type0) + && gnu_vector_type_p (type1) && (!tree_int_cst_equal (TYPE_SIZE (type0), TYPE_SIZE (type1)) || !vector_types_compatible_elements_p (type0, type1))) { @@ -12237,10 +12248,12 @@ build_binary_op (location_t location, enum tree_code code, } if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE || code0 == COMPLEX_TYPE - || code0 == FIXED_POINT_TYPE || code0 == VECTOR_TYPE) + || code0 == FIXED_POINT_TYPE + || gnu_vector_type_p (type0)) && (code1 == INTEGER_TYPE || code1 == REAL_TYPE || code1 == COMPLEX_TYPE - || code1 == FIXED_POINT_TYPE || code1 == VECTOR_TYPE)) + || code1 == FIXED_POINT_TYPE + || gnu_vector_type_p (type1))) { bool first_complex = (code0 == COMPLEX_TYPE); bool second_complex = (code1 == COMPLEX_TYPE); diff --git a/gcc/config/aarch64/aarch64-sve-builtins.cc b/gcc/config/aarch64/aarch64-sve-builtins.cc index 424f64a..bb5aada 100644 --- a/gcc/config/aarch64/aarch64-sve-builtins.cc +++ b/gcc/config/aarch64/aarch64-sve-builtins.cc @@ -2996,6 +2996,7 @@ register_builtin_types () gcc_assert (vectype == TYPE_MAIN_VARIANT (vectype)); SET_TYPE_STRUCTURAL_EQUALITY (vectype); TYPE_ARTIFICIAL (vectype) = 1; + TYPE_INDIVISIBLE_P (vectype) = 1; abi_vector_types[i] = vectype; lang_hooks.types.register_builtin_type (vectype, vector_types[i].abi_name); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9fbff8b..22f15fd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-11-08 Richard Sandiford <richard.sandiford@arm.com> + + * gcc.target/aarch64/sve/acle/general-c/gnu_vectors_1.c: New test. + * gcc.target/aarch64/sve/acle/general-c/gnu_vectors_2.c: Likewise. + 2019-11-08 Kewen Lin <linkw@gcc.gnu.org> PR target/92132 diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/gnu_vectors_1.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/gnu_vectors_1.c new file mode 100644 index 0000000..285751e --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/gnu_vectors_1.c @@ -0,0 +1,415 @@ +/* { dg-options "-msve-vector-bits=256" } */ + +#include <arm_sve.h> + +typedef uint8_t gnu_uint8_t __attribute__ ((vector_size (32))); +typedef int8_t gnu_int8_t __attribute__ ((vector_size (32))); + +void +f (svuint8_t sve_u1, svint8_t sve_s1, + gnu_uint8_t gnu_u1, gnu_int8_t gnu_s1, int n, unsigned char uc) +{ + /* Initialization. */ + + svuint8_t init_sve_u1 = 0; /* { dg-error {incompatible types when initializing type 'svuint8_t' using type 'int'} } */ + svuint8_t init_sve_u2 = {}; /* { dg-error {empty scalar initializer} } */ + svuint8_t init_sve_u3 = { sve_u1 }; + svuint8_t init_sve_u4 = { gnu_u1 }; + svuint8_t init_sve_u5 = { sve_s1 }; /* { dg-error {incompatible types when initializing type 'svuint8_t' using type 'svint8_t'} } */ + svuint8_t init_sve_u6 = { gnu_s1 }; /* { dg-error {incompatible types when initializing type 'svuint8_t'} } */ + svuint8_t init_sve_u7 = { 0 }; /* { dg-error {incompatible types when initializing type 'svuint8_t' using type 'int'} } */ + svuint8_t init_sve_u8 = { sve_u1, sve_u1 }; /* { dg-warning {excess elements in scalar initializer} } */ + svuint8_t init_sve_u9 = { gnu_u1, gnu_u1 }; /* { dg-warning {excess elements in scalar initializer} } */ + + gnu_uint8_t init_gnu_u1 = 0; /* { dg-error {incompatible types when initializing type 'gnu_uint8_t'[^\n]* using type 'int'} } */ + gnu_uint8_t init_gnu_u2 = {}; + gnu_uint8_t init_gnu_u3 = { sve_u1 }; /* { dg-error {incompatible types when initializing type 'unsigned char'} } */ + gnu_uint8_t init_gnu_u4 = { gnu_u1 }; /* { dg-error {incompatible types when initializing type 'unsigned char'} } */ + gnu_uint8_t init_gnu_u5 = { sve_s1 }; /* { dg-error {incompatible types when initializing type 'unsigned char'} } */ + gnu_uint8_t init_gnu_u6 = { gnu_s1 }; /* { dg-error {incompatible types when initializing type 'unsigned char'} } */ + gnu_uint8_t init_gnu_u7 = { 0 }; + + /* Compound literals. */ + + (svuint8_t) {}; /* { dg-error {empty scalar initializer} } */ + (svuint8_t) { 0 }; /* { dg-error {incompatible types when initializing type 'svuint8_t' using type 'int'} } */ + (svuint8_t) { sve_u1 }; + (svuint8_t) { gnu_u1 }; + (svuint8_t) { sve_s1 }; /* { dg-error {incompatible types when initializing type 'svuint8_t' using type 'svint8_t'} } */ + (svuint8_t) { gnu_s1 }; /* { dg-error {incompatible types when initializing type 'svuint8_t'} } */ + + (gnu_uint8_t) {}; + (gnu_uint8_t) { 0 }; + (gnu_uint8_t) { sve_u1 }; /* { dg-error {incompatible types when initializing type 'unsigned char'} } */ + (gnu_uint8_t) { gnu_u1 }; /* { dg-error {incompatible types when initializing type 'unsigned char'} } */ + + /* Assignment. */ + + sve_u1 = 0; /* { dg-error {incompatible types when assigning to type 'svuint8_t' from type 'int'} } */ + sve_u1 = sve_u1; + sve_u1 = gnu_u1; + sve_u1 = sve_s1; /* { dg-error {incompatible types when assigning to type 'svuint8_t' from type 'svint8_t'} } */ + sve_u1 = gnu_s1; /* { dg-error {incompatible types when assigning to type 'svuint8_t' from type 'gnu_int8_t'} } */ + + gnu_u1 = 0; /* { dg-error {incompatible types when assigning to type 'gnu_uint8_t'[^\n]* from type 'int'} } */ + gnu_u1 = sve_u1; + gnu_u1 = gnu_u1; + gnu_u1 = sve_s1; /* { dg-error {incompatible types when assigning to type 'gnu_uint8_t'[^\n]* from type 'svint8_t'} } */ + gnu_u1 = gnu_s1; /* { dg-error {incompatible types when assigning to type 'gnu_uint8_t'[^\n]* from type 'gnu_int8_t'} } */ + + /* Casts. */ + + (void) sve_u1; + (svuint8_t) sve_u1; + (svuint8_t) gnu_u1; + (svuint8_t) 0; /* { dg-error {conversion to non-scalar type requested} } */ + (svuint8_t) n; /* { dg-error {conversion to non-scalar type requested} } */ + (svint8_t) sve_u1; /* { dg-error {conversion to non-scalar type requested} } */ + (svint8_t) gnu_u1; + + (void) gnu_u1; + (gnu_uint8_t) sve_u1; + (gnu_uint8_t) gnu_u1; + (gnu_uint8_t) 0; /* { dg-error {cannot convert a value of type 'int' to vector type '[^']*' which has different size} } */ + (gnu_uint8_t) n; /* { dg-error {cannot convert a value of type 'int' to vector type '[^']*' which has different size} } */ + (gnu_int8_t) sve_u1; + (gnu_int8_t) gnu_u1; + + /* Vector indexing. */ + + sve_u1[0]; /* { dg-error {subscripted value is neither array nor pointer} } */ + &sve_u1[0]; /* { dg-error {subscripted value is neither array nor pointer} } */ + + gnu_u1[0]; + &gnu_u1[0]; + + /* Unary operators. */ + + +sve_u1; /* { dg-error {wrong type argument to unary plus} } */ + -sve_u1; /* { dg-error {wrong type argument to unary minus} } */ + ~sve_u1; /* { dg-error {wrong type argument to bit-complement} } */ + !sve_u1; /* { dg-error {wrong type argument to unary exclamation mark} } */ + *sve_u1; /* { dg-error {invalid type argument of unary '\*'} } */ + __real sve_u1; /* { dg-error {wrong type argument to __real} } */ + __imag sve_u1; /* { dg-error {wrong type argument to __imag} } */ + ++sve_u1; /* { dg-error {wrong type argument to increment} } */ + --sve_u1; /* { dg-error {wrong type argument to decrement} } */ + sve_u1++; /* { dg-error {wrong type argument to increment} } */ + sve_u1--; /* { dg-error {wrong type argument to decrement} } */ + + +gnu_u1; + -gnu_u1; + ~gnu_u1; + !gnu_u1; /* { dg-error {wrong type argument to unary exclamation mark} } */ + *gnu_u1; /* { dg-error {invalid type argument of unary '\*'} } */ + __real gnu_u1; /* { dg-error {wrong type argument to __real} } */ + __imag gnu_u1; /* { dg-error {wrong type argument to __imag} } */ + ++gnu_u1; + --gnu_u1; + gnu_u1++; + gnu_u1--; + + /* Vector-vector binary arithmetic. */ + + sve_u1 + sve_u1; /* { dg-error {invalid operands to binary \+} } */ + sve_u1 - sve_u1; /* { dg-error {invalid operands to binary -} } */ + sve_u1 * sve_u1; /* { dg-error {invalid operands to binary \*} } */ + sve_u1 / sve_u1; /* { dg-error {invalid operands to binary /} } */ + sve_u1 % sve_u1; /* { dg-error {invalid operands to binary %} } */ + sve_u1 & sve_u1; /* { dg-error {invalid operands to binary \&} } */ + sve_u1 | sve_u1; /* { dg-error {invalid operands to binary \|} } */ + sve_u1 ^ sve_u1; /* { dg-error {invalid operands to binary \^} } */ + sve_u1 == sve_u1; /* { dg-error {invalid operands to binary ==} } */ + sve_u1 != sve_u1; /* { dg-error {invalid operands to binary !=} } */ + sve_u1 <= sve_u1; /* { dg-error {invalid operands to binary <=} } */ + sve_u1 < sve_u1; /* { dg-error {invalid operands to binary <} } */ + sve_u1 > sve_u1; /* { dg-error {invalid operands to binary >} } */ + sve_u1 >= sve_u1; /* { dg-error {invalid operands to binary >=} } */ + sve_u1 << sve_u1; /* { dg-error {invalid operands to binary <<} } */ + sve_u1 >> sve_u1; /* { dg-error {invalid operands to binary >>} } */ + sve_u1 && sve_u1; /* { dg-error {used vector type where scalar is required} } */ + sve_u1 || sve_u1; /* { dg-error {used vector type where scalar is required} } */ + + sve_u1 + gnu_u1; /* { dg-error {invalid operands to binary \+} } */ + sve_u1 - gnu_u1; /* { dg-error {invalid operands to binary -} } */ + sve_u1 * gnu_u1; /* { dg-error {invalid operands to binary \*} } */ + sve_u1 / gnu_u1; /* { dg-error {invalid operands to binary /} } */ + sve_u1 % gnu_u1; /* { dg-error {invalid operands to binary %} } */ + sve_u1 & gnu_u1; /* { dg-error {invalid operands to binary \&} } */ + sve_u1 | gnu_u1; /* { dg-error {invalid operands to binary \|} } */ + sve_u1 ^ gnu_u1; /* { dg-error {invalid operands to binary \^} } */ + sve_u1 == gnu_u1; /* { dg-error {invalid operands to binary ==} } */ + sve_u1 != gnu_u1; /* { dg-error {invalid operands to binary !=} } */ + sve_u1 <= gnu_u1; /* { dg-error {invalid operands to binary <=} } */ + sve_u1 < gnu_u1; /* { dg-error {invalid operands to binary <} } */ + sve_u1 > gnu_u1; /* { dg-error {invalid operands to binary >} } */ + sve_u1 >= gnu_u1; /* { dg-error {invalid operands to binary >=} } */ + sve_u1 << gnu_u1; /* { dg-error {invalid operands to binary <<} } */ + sve_u1 >> gnu_u1; /* { dg-error {invalid operands to binary >>} } */ + sve_u1 && gnu_u1; /* { dg-error {used vector type where scalar is required} } */ + sve_u1 || gnu_u1; /* { dg-error {used vector type where scalar is required} } */ + + gnu_u1 + sve_u1; /* { dg-error {invalid operands to binary \+} } */ + gnu_u1 - sve_u1; /* { dg-error {invalid operands to binary -} } */ + gnu_u1 * sve_u1; /* { dg-error {invalid operands to binary \*} } */ + gnu_u1 / sve_u1; /* { dg-error {invalid operands to binary /} } */ + gnu_u1 % sve_u1; /* { dg-error {invalid operands to binary %} } */ + gnu_u1 & sve_u1; /* { dg-error {invalid operands to binary \&} } */ + gnu_u1 | sve_u1; /* { dg-error {invalid operands to binary \|} } */ + gnu_u1 ^ sve_u1; /* { dg-error {invalid operands to binary \^} } */ + gnu_u1 == sve_u1; /* { dg-error {invalid operands to binary ==} } */ + gnu_u1 != sve_u1; /* { dg-error {invalid operands to binary !=} } */ + gnu_u1 <= sve_u1; /* { dg-error {invalid operands to binary <=} } */ + gnu_u1 < sve_u1; /* { dg-error {invalid operands to binary <} } */ + gnu_u1 > sve_u1; /* { dg-error {invalid operands to binary >} } */ + gnu_u1 >= sve_u1; /* { dg-error {invalid operands to binary >=} } */ + gnu_u1 << sve_u1; /* { dg-error {invalid operands to binary <<} } */ + gnu_u1 >> sve_u1; /* { dg-error {invalid operands to binary >>} } */ + gnu_u1 && sve_u1; /* { dg-error {used vector type where scalar is required} } */ + gnu_u1 || sve_u1; /* { dg-error {used vector type where scalar is required} } */ + + gnu_u1 + gnu_u1; + gnu_u1 - gnu_u1; + gnu_u1 * gnu_u1; + gnu_u1 / gnu_u1; + gnu_u1 % gnu_u1; + gnu_u1 & gnu_u1; + gnu_u1 | gnu_u1; + gnu_u1 ^ gnu_u1; + gnu_u1 == gnu_u1; + gnu_u1 != gnu_u1; + gnu_u1 <= gnu_u1; + gnu_u1 < gnu_u1; + gnu_u1 > gnu_u1; + gnu_u1 >= gnu_u1; + gnu_u1 << gnu_u1; + gnu_u1 >> gnu_u1; + gnu_u1 && gnu_u1; /* { dg-error {used vector type where scalar is required} } */ + gnu_u1 || gnu_u1; /* { dg-error {used vector type where scalar is required} } */ + + /* Vector-scalar binary arithmetic. */ + + sve_u1 + 2; /* { dg-error {invalid operands to binary \+} } */ + sve_u1 - 2; /* { dg-error {invalid operands to binary -} } */ + sve_u1 * 2; /* { dg-error {invalid operands to binary \*} } */ + sve_u1 / 2; /* { dg-error {invalid operands to binary /} } */ + sve_u1 % 2; /* { dg-error {invalid operands to binary %} } */ + sve_u1 & 2; /* { dg-error {invalid operands to binary \&} } */ + sve_u1 | 2; /* { dg-error {invalid operands to binary \|} } */ + sve_u1 ^ 2; /* { dg-error {invalid operands to binary \^} } */ + sve_u1 == 2; /* { dg-error {invalid operands to binary ==} } */ + sve_u1 != 2; /* { dg-error {invalid operands to binary !=} } */ + sve_u1 <= 2; /* { dg-error {invalid operands to binary <=} } */ + sve_u1 < 2; /* { dg-error {invalid operands to binary <} } */ + sve_u1 > 2; /* { dg-error {invalid operands to binary >} } */ + sve_u1 >= 2; /* { dg-error {invalid operands to binary >=} } */ + sve_u1 << 2; /* { dg-error {invalid operands to binary <<} } */ + sve_u1 >> 2; /* { dg-error {invalid operands to binary >>} } */ + sve_u1 && 2; /* { dg-error {used vector type where scalar is required} } */ + sve_u1 || 2; /* { dg-error {used vector type where scalar is required} } */ + + sve_u1 + uc; /* { dg-error {invalid operands to binary \+} } */ + sve_u1 - uc; /* { dg-error {invalid operands to binary -} } */ + sve_u1 * uc; /* { dg-error {invalid operands to binary \*} } */ + sve_u1 / uc; /* { dg-error {invalid operands to binary /} } */ + sve_u1 % uc; /* { dg-error {invalid operands to binary %} } */ + sve_u1 & uc; /* { dg-error {invalid operands to binary \&} } */ + sve_u1 | uc; /* { dg-error {invalid operands to binary \|} } */ + sve_u1 ^ uc; /* { dg-error {invalid operands to binary \^} } */ + sve_u1 == uc; /* { dg-error {invalid operands to binary ==} } */ + sve_u1 != uc; /* { dg-error {invalid operands to binary !=} } */ + sve_u1 <= uc; /* { dg-error {invalid operands to binary <=} } */ + sve_u1 < uc; /* { dg-error {invalid operands to binary <} } */ + sve_u1 > uc; /* { dg-error {invalid operands to binary >} } */ + sve_u1 >= uc; /* { dg-error {invalid operands to binary >=} } */ + sve_u1 << uc; /* { dg-error {invalid operands to binary <<} } */ + sve_u1 >> uc; /* { dg-error {invalid operands to binary >>} } */ + sve_u1 && uc; /* { dg-error {used vector type where scalar is required} } */ + sve_u1 || uc; /* { dg-error {used vector type where scalar is required} } */ + + gnu_u1 + 2; + gnu_u1 - 2; + gnu_u1 * 2; + gnu_u1 / 2; + gnu_u1 % 2; + gnu_u1 & 2; + gnu_u1 | 2; + gnu_u1 ^ 2; + gnu_u1 == 2; + gnu_u1 != 2; + gnu_u1 <= 2; + gnu_u1 < 2; + gnu_u1 > 2; + gnu_u1 >= 2; + gnu_u1 << 2; + gnu_u1 >> 2; + gnu_u1 && 2; /* { dg-error {used vector type where scalar is required} } */ + gnu_u1 || 2; /* { dg-error {used vector type where scalar is required} } */ + + gnu_u1 + uc; + gnu_u1 - uc; + gnu_u1 * uc; + gnu_u1 / uc; + gnu_u1 % uc; + gnu_u1 & uc; + gnu_u1 | uc; + gnu_u1 ^ uc; + gnu_u1 == uc; + gnu_u1 != uc; + gnu_u1 <= uc; + gnu_u1 < uc; + gnu_u1 > uc; + gnu_u1 >= uc; + gnu_u1 << uc; + gnu_u1 >> uc; + gnu_u1 && uc; /* { dg-error {used vector type where scalar is required} } */ + gnu_u1 || uc; /* { dg-error {used vector type where scalar is required} } */ + + /* Scalar-vector binary arithmetic. */ + + 3 + sve_u1; /* { dg-error {invalid operands to binary \+} } */ + 3 - sve_u1; /* { dg-error {invalid operands to binary -} } */ + 3 * sve_u1; /* { dg-error {invalid operands to binary \*} } */ + 3 / sve_u1; /* { dg-error {invalid operands to binary /} } */ + 3 % sve_u1; /* { dg-error {invalid operands to binary %} } */ + 3 & sve_u1; /* { dg-error {invalid operands to binary \&} } */ + 3 | sve_u1; /* { dg-error {invalid operands to binary \|} } */ + 3 ^ sve_u1; /* { dg-error {invalid operands to binary \^} } */ + 3 == sve_u1; /* { dg-error {invalid operands to binary ==} } */ + 3 != sve_u1; /* { dg-error {invalid operands to binary !=} } */ + 3 <= sve_u1; /* { dg-error {invalid operands to binary <=} } */ + 3 < sve_u1; /* { dg-error {invalid operands to binary <} } */ + 3 > sve_u1; /* { dg-error {invalid operands to binary >} } */ + 3 >= sve_u1; /* { dg-error {invalid operands to binary >=} } */ + 3 << sve_u1; /* { dg-error {invalid operands to binary <<} } */ + 3 >> sve_u1; /* { dg-error {invalid operands to binary >>} } */ + 3 && sve_u1; /* { dg-error {invalid operands to binary \&\&} } */ + 3 || sve_u1; /* { dg-error {invalid operands to binary \|\|} } */ + + 3 + gnu_u1; + 3 - gnu_u1; + 3 * gnu_u1; + 3 / gnu_u1; + 3 % gnu_u1; + 3 & gnu_u1; + 3 | gnu_u1; + 3 ^ gnu_u1; + 3 == gnu_u1; + 3 != gnu_u1; + 3 <= gnu_u1; + 3 < gnu_u1; + 3 > gnu_u1; + 3 >= gnu_u1; + 3 << gnu_u1; + 3 >> gnu_u1; + 3 && gnu_u1; /* { dg-error {invalid operands to binary \&\&} } */ + 3 || gnu_u1; /* { dg-error {invalid operands to binary \|\|} } */ + + /* Mismatched types. */ + + sve_u1 + sve_s1; /* { dg-error {invalid operands to binary \+} } */ + sve_u1 - sve_s1; /* { dg-error {invalid operands to binary -} } */ + sve_u1 * sve_s1; /* { dg-error {invalid operands to binary \*} } */ + sve_u1 / sve_s1; /* { dg-error {invalid operands to binary /} } */ + sve_u1 % sve_s1; /* { dg-error {invalid operands to binary %} } */ + sve_u1 & sve_s1; /* { dg-error {invalid operands to binary \&} } */ + sve_u1 | sve_s1; /* { dg-error {invalid operands to binary \|} } */ + sve_u1 ^ sve_s1; /* { dg-error {invalid operands to binary \^} } */ + sve_u1 == sve_s1; /* { dg-error {invalid operands to binary ==} } */ + sve_u1 != sve_s1; /* { dg-error {invalid operands to binary !=} } */ + sve_u1 <= sve_s1; /* { dg-error {invalid operands to binary <=} } */ + sve_u1 < sve_s1; /* { dg-error {invalid operands to binary <} } */ + sve_u1 > sve_s1; /* { dg-error {invalid operands to binary >} } */ + sve_u1 >= sve_s1; /* { dg-error {invalid operands to binary >=} } */ + sve_u1 << sve_s1; /* { dg-error {invalid operands to binary <<} } */ + sve_u1 >> sve_s1; /* { dg-error {invalid operands to binary >>} } */ + sve_u1 && sve_s1; /* { dg-error {used vector type where scalar is required} } */ + sve_u1 || sve_s1; /* { dg-error {used vector type where scalar is required} } */ + + sve_u1 + gnu_s1; /* { dg-error {invalid operands to binary \+} } */ + sve_u1 - gnu_s1; /* { dg-error {invalid operands to binary -} } */ + sve_u1 * gnu_s1; /* { dg-error {invalid operands to binary \*} } */ + sve_u1 / gnu_s1; /* { dg-error {invalid operands to binary /} } */ + sve_u1 % gnu_s1; /* { dg-error {invalid operands to binary %} } */ + sve_u1 & gnu_s1; /* { dg-error {invalid operands to binary \&} } */ + sve_u1 | gnu_s1; /* { dg-error {invalid operands to binary \|} } */ + sve_u1 ^ gnu_s1; /* { dg-error {invalid operands to binary \^} } */ + sve_u1 == gnu_s1; /* { dg-error {invalid operands to binary ==} } */ + sve_u1 != gnu_s1; /* { dg-error {invalid operands to binary !=} } */ + sve_u1 <= gnu_s1; /* { dg-error {invalid operands to binary <=} } */ + sve_u1 < gnu_s1; /* { dg-error {invalid operands to binary <} } */ + sve_u1 > gnu_s1; /* { dg-error {invalid operands to binary >} } */ + sve_u1 >= gnu_s1; /* { dg-error {invalid operands to binary >=} } */ + sve_u1 << gnu_s1; /* { dg-error {invalid operands to binary <<} } */ + sve_u1 >> gnu_s1; /* { dg-error {invalid operands to binary >>} } */ + sve_u1 && gnu_s1; /* { dg-error {used vector type where scalar is required} } */ + sve_u1 || gnu_s1; /* { dg-error {used vector type where scalar is required} } */ + + gnu_u1 + sve_s1; /* { dg-error {invalid operands to binary \+} } */ + gnu_u1 - sve_s1; /* { dg-error {invalid operands to binary -} } */ + gnu_u1 * sve_s1; /* { dg-error {invalid operands to binary \*} } */ + gnu_u1 / sve_s1; /* { dg-error {invalid operands to binary /} } */ + gnu_u1 % sve_s1; /* { dg-error {invalid operands to binary %} } */ + gnu_u1 & sve_s1; /* { dg-error {invalid operands to binary \&} } */ + gnu_u1 | sve_s1; /* { dg-error {invalid operands to binary \|} } */ + gnu_u1 ^ sve_s1; /* { dg-error {invalid operands to binary \^} } */ + gnu_u1 == sve_s1; /* { dg-error {invalid operands to binary ==} } */ + gnu_u1 != sve_s1; /* { dg-error {invalid operands to binary !=} } */ + gnu_u1 <= sve_s1; /* { dg-error {invalid operands to binary <=} } */ + gnu_u1 < sve_s1; /* { dg-error {invalid operands to binary <} } */ + gnu_u1 > sve_s1; /* { dg-error {invalid operands to binary >} } */ + gnu_u1 >= sve_s1; /* { dg-error {invalid operands to binary >=} } */ + gnu_u1 << sve_s1; /* { dg-error {invalid operands to binary <<} } */ + gnu_u1 >> sve_s1; /* { dg-error {invalid operands to binary >>} } */ + gnu_u1 && sve_s1; /* { dg-error {used vector type where scalar is required} } */ + gnu_u1 || sve_s1; /* { dg-error {used vector type where scalar is required} } */ + + gnu_u1 + gnu_s1; + gnu_u1 - gnu_s1; + gnu_u1 * gnu_s1; + gnu_u1 / gnu_s1; + gnu_u1 % gnu_s1; + gnu_u1 & gnu_s1; + gnu_u1 | gnu_s1; + gnu_u1 ^ gnu_s1; + gnu_u1 == gnu_s1; + gnu_u1 != gnu_s1; + gnu_u1 <= gnu_s1; + gnu_u1 < gnu_s1; + gnu_u1 > gnu_s1; + gnu_u1 >= gnu_s1; + gnu_u1 << gnu_s1; + gnu_u1 >> gnu_s1; + gnu_u1 && gnu_s1; /* { dg-error {used vector type where scalar is required} } */ + gnu_u1 || gnu_s1; /* { dg-error {used vector type where scalar is required} } */ + + /* Conditional expressions. */ + + uc ? sve_u1 : sve_u1; + uc ? gnu_u1 : sve_u1; /* { dg-error {type mismatch in conditional expression} } */ + uc ? sve_u1 : gnu_u1; /* { dg-error {type mismatch in conditional expression} } */ + uc ? gnu_u1 : gnu_u1; + + sve_u1 ? sve_u1 : sve_u1; /* { dg-error {used vector type where scalar is required} } */ + sve_u1 ? gnu_u1 : sve_u1; /* { dg-error {used vector type where scalar is required} } */ + sve_u1 ? sve_u1 : gnu_u1; /* { dg-error {used vector type where scalar is required} } */ + sve_u1 ? gnu_u1 : gnu_u1; /* { dg-error {used vector type where scalar is required} } */ + + gnu_u1 ? sve_u1 : sve_u1; /* { dg-error {used vector type where scalar is required} } */ + gnu_u1 ? gnu_u1 : sve_u1; /* { dg-error {used vector type where scalar is required} } */ + gnu_u1 ? sve_u1 : gnu_u1; /* { dg-error {used vector type where scalar is required} } */ + gnu_u1 ? gnu_u1 : gnu_u1; /* { dg-error {used vector type where scalar is required} } */ + + /* Vector built-ins. */ + + __builtin_shuffle (sve_u1, sve_u1, sve_u1); /* { dg-error {'__builtin_shuffle' last argument must be an integer vector} } */ + __builtin_shuffle (sve_u1, gnu_u1, gnu_u1); /* { dg-error {'__builtin_shuffle' arguments must be vectors} } */ + __builtin_shuffle (gnu_u1, sve_u1, gnu_u1); /* { dg-error {'__builtin_shuffle' arguments must be vectors} } */ + __builtin_shuffle (gnu_u1, gnu_u1, sve_u1); /* { dg-error {'__builtin_shuffle' last argument must be an integer vector} } */ + __builtin_shuffle (gnu_u1, gnu_u1, gnu_u1); + + __builtin_convertvector (sve_u1, svuint8_t); /* { dg-error {'__builtin_convertvector' first argument must be an integer or floating vector} } */ + __builtin_convertvector (gnu_u1, svuint8_t); /* { dg-error {'__builtin_convertvector' second argument must be an integer or floating vector type} } */ + __builtin_convertvector (sve_u1, gnu_uint8_t); /* { dg-error {'__builtin_convertvector' first argument must be an integer or floating vector} } */ + __builtin_convertvector (gnu_u1, gnu_uint8_t); +} diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/gnu_vectors_2.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/gnu_vectors_2.c new file mode 100644 index 0000000..306fd47 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/gnu_vectors_2.c @@ -0,0 +1,415 @@ +/* { dg-options "-msve-vector-bits=256 -flax-vector-conversions" } */ + +#include <arm_sve.h> + +typedef uint8_t gnu_uint8_t __attribute__ ((vector_size (32))); +typedef int8_t gnu_int8_t __attribute__ ((vector_size (32))); + +void +f (svuint8_t sve_u1, svint8_t sve_s1, + gnu_uint8_t gnu_u1, gnu_int8_t gnu_s1, int n, unsigned char uc) +{ + /* Initialization. */ + + svuint8_t init_sve_u1 = 0; /* { dg-error {incompatible types when initializing type 'svuint8_t' using type 'int'} } */ + svuint8_t init_sve_u2 = {}; /* { dg-error {empty scalar initializer} } */ + svuint8_t init_sve_u3 = { sve_u1 }; + svuint8_t init_sve_u4 = { gnu_u1 }; + svuint8_t init_sve_u5 = { sve_s1 }; + svuint8_t init_sve_u6 = { gnu_s1 }; + svuint8_t init_sve_u7 = { 0 }; /* { dg-error {incompatible types when initializing type 'svuint8_t' using type 'int'} } */ + svuint8_t init_sve_u8 = { sve_u1, sve_u1 }; /* { dg-warning {excess elements in scalar initializer} } */ + svuint8_t init_sve_u9 = { gnu_u1, gnu_u1 }; /* { dg-warning {excess elements in scalar initializer} } */ + + gnu_uint8_t init_gnu_u1 = 0; /* { dg-error {incompatible types when initializing type 'gnu_uint8_t'[^\n]* using type 'int'} } */ + gnu_uint8_t init_gnu_u2 = {}; + gnu_uint8_t init_gnu_u3 = { sve_u1 }; /* { dg-error {incompatible types when initializing type 'unsigned char'} } */ + gnu_uint8_t init_gnu_u4 = { gnu_u1 }; /* { dg-error {incompatible types when initializing type 'unsigned char'} } */ + gnu_uint8_t init_gnu_u5 = { sve_s1 }; /* { dg-error {incompatible types when initializing type 'unsigned char'} } */ + gnu_uint8_t init_gnu_u6 = { gnu_s1 }; /* { dg-error {incompatible types when initializing type 'unsigned char'} } */ + gnu_uint8_t init_gnu_u7 = { 0 }; + + /* Compound literals. */ + + (svuint8_t) {}; /* { dg-error {empty scalar initializer} } */ + (svuint8_t) { 0 }; /* { dg-error {incompatible types when initializing type 'svuint8_t' using type 'int'} } */ + (svuint8_t) { sve_u1 }; + (svuint8_t) { gnu_u1 }; + (svuint8_t) { sve_s1 }; + (svuint8_t) { gnu_s1 }; + + (gnu_uint8_t) {}; + (gnu_uint8_t) { 0 }; + (gnu_uint8_t) { sve_u1 }; /* { dg-error {incompatible types when initializing type 'unsigned char'} } */ + (gnu_uint8_t) { gnu_u1 }; /* { dg-error {incompatible types when initializing type 'unsigned char'} } */ + + /* Assignment. */ + + sve_u1 = 0; /* { dg-error {incompatible types when assigning to type 'svuint8_t' from type 'int'} } */ + sve_u1 = sve_u1; + sve_u1 = gnu_u1; + sve_u1 = sve_s1; + sve_u1 = gnu_s1; + + gnu_u1 = 0; /* { dg-error {incompatible types when assigning to type 'gnu_uint8_t'[^\n]* from type 'int'} } */ + gnu_u1 = sve_u1; + gnu_u1 = gnu_u1; + gnu_u1 = sve_s1; + gnu_u1 = gnu_s1; + + /* Casts. */ + + (void) sve_u1; + (svuint8_t) sve_u1; + (svuint8_t) gnu_u1; + (svuint8_t) 0; /* { dg-error {conversion to non-scalar type requested} } */ + (svuint8_t) n; /* { dg-error {conversion to non-scalar type requested} } */ + (svint8_t) sve_u1; + (svint8_t) gnu_u1; + + (void) gnu_u1; + (gnu_uint8_t) sve_u1; + (gnu_uint8_t) gnu_u1; + (gnu_uint8_t) 0; /* { dg-error {cannot convert a value of type 'int' to vector type '[^']*' which has different size} } */ + (gnu_uint8_t) n; /* { dg-error {cannot convert a value of type 'int' to vector type '[^']*' which has different size} } */ + (gnu_int8_t) sve_u1; + (gnu_int8_t) gnu_u1; + + /* Vector indexing. */ + + sve_u1[0]; /* { dg-error {subscripted value is neither array nor pointer} } */ + &sve_u1[0]; /* { dg-error {subscripted value is neither array nor pointer} } */ + + gnu_u1[0]; + &gnu_u1[0]; + + /* Unary operators. */ + + +sve_u1; /* { dg-error {wrong type argument to unary plus} } */ + -sve_u1; /* { dg-error {wrong type argument to unary minus} } */ + ~sve_u1; /* { dg-error {wrong type argument to bit-complement} } */ + !sve_u1; /* { dg-error {wrong type argument to unary exclamation mark} } */ + *sve_u1; /* { dg-error {invalid type argument of unary '\*'} } */ + __real sve_u1; /* { dg-error {wrong type argument to __real} } */ + __imag sve_u1; /* { dg-error {wrong type argument to __imag} } */ + ++sve_u1; /* { dg-error {wrong type argument to increment} } */ + --sve_u1; /* { dg-error {wrong type argument to decrement} } */ + sve_u1++; /* { dg-error {wrong type argument to increment} } */ + sve_u1--; /* { dg-error {wrong type argument to decrement} } */ + + +gnu_u1; + -gnu_u1; + ~gnu_u1; + !gnu_u1; /* { dg-error {wrong type argument to unary exclamation mark} } */ + *gnu_u1; /* { dg-error {invalid type argument of unary '\*'} } */ + __real gnu_u1; /* { dg-error {wrong type argument to __real} } */ + __imag gnu_u1; /* { dg-error {wrong type argument to __imag} } */ + ++gnu_u1; + --gnu_u1; + gnu_u1++; + gnu_u1--; + + /* Vector-vector binary arithmetic. */ + + sve_u1 + sve_u1; /* { dg-error {invalid operands to binary \+} } */ + sve_u1 - sve_u1; /* { dg-error {invalid operands to binary -} } */ + sve_u1 * sve_u1; /* { dg-error {invalid operands to binary \*} } */ + sve_u1 / sve_u1; /* { dg-error {invalid operands to binary /} } */ + sve_u1 % sve_u1; /* { dg-error {invalid operands to binary %} } */ + sve_u1 & sve_u1; /* { dg-error {invalid operands to binary \&} } */ + sve_u1 | sve_u1; /* { dg-error {invalid operands to binary \|} } */ + sve_u1 ^ sve_u1; /* { dg-error {invalid operands to binary \^} } */ + sve_u1 == sve_u1; /* { dg-error {invalid operands to binary ==} } */ + sve_u1 != sve_u1; /* { dg-error {invalid operands to binary !=} } */ + sve_u1 <= sve_u1; /* { dg-error {invalid operands to binary <=} } */ + sve_u1 < sve_u1; /* { dg-error {invalid operands to binary <} } */ + sve_u1 > sve_u1; /* { dg-error {invalid operands to binary >} } */ + sve_u1 >= sve_u1; /* { dg-error {invalid operands to binary >=} } */ + sve_u1 << sve_u1; /* { dg-error {invalid operands to binary <<} } */ + sve_u1 >> sve_u1; /* { dg-error {invalid operands to binary >>} } */ + sve_u1 && sve_u1; /* { dg-error {used vector type where scalar is required} } */ + sve_u1 || sve_u1; /* { dg-error {used vector type where scalar is required} } */ + + sve_u1 + gnu_u1; /* { dg-error {invalid operands to binary \+} } */ + sve_u1 - gnu_u1; /* { dg-error {invalid operands to binary -} } */ + sve_u1 * gnu_u1; /* { dg-error {invalid operands to binary \*} } */ + sve_u1 / gnu_u1; /* { dg-error {invalid operands to binary /} } */ + sve_u1 % gnu_u1; /* { dg-error {invalid operands to binary %} } */ + sve_u1 & gnu_u1; /* { dg-error {invalid operands to binary \&} } */ + sve_u1 | gnu_u1; /* { dg-error {invalid operands to binary \|} } */ + sve_u1 ^ gnu_u1; /* { dg-error {invalid operands to binary \^} } */ + sve_u1 == gnu_u1; /* { dg-error {invalid operands to binary ==} } */ + sve_u1 != gnu_u1; /* { dg-error {invalid operands to binary !=} } */ + sve_u1 <= gnu_u1; /* { dg-error {invalid operands to binary <=} } */ + sve_u1 < gnu_u1; /* { dg-error {invalid operands to binary <} } */ + sve_u1 > gnu_u1; /* { dg-error {invalid operands to binary >} } */ + sve_u1 >= gnu_u1; /* { dg-error {invalid operands to binary >=} } */ + sve_u1 << gnu_u1; /* { dg-error {invalid operands to binary <<} } */ + sve_u1 >> gnu_u1; /* { dg-error {invalid operands to binary >>} } */ + sve_u1 && gnu_u1; /* { dg-error {used vector type where scalar is required} } */ + sve_u1 || gnu_u1; /* { dg-error {used vector type where scalar is required} } */ + + gnu_u1 + sve_u1; /* { dg-error {invalid operands to binary \+} } */ + gnu_u1 - sve_u1; /* { dg-error {invalid operands to binary -} } */ + gnu_u1 * sve_u1; /* { dg-error {invalid operands to binary \*} } */ + gnu_u1 / sve_u1; /* { dg-error {invalid operands to binary /} } */ + gnu_u1 % sve_u1; /* { dg-error {invalid operands to binary %} } */ + gnu_u1 & sve_u1; /* { dg-error {invalid operands to binary \&} } */ + gnu_u1 | sve_u1; /* { dg-error {invalid operands to binary \|} } */ + gnu_u1 ^ sve_u1; /* { dg-error {invalid operands to binary \^} } */ + gnu_u1 == sve_u1; /* { dg-error {invalid operands to binary ==} } */ + gnu_u1 != sve_u1; /* { dg-error {invalid operands to binary !=} } */ + gnu_u1 <= sve_u1; /* { dg-error {invalid operands to binary <=} } */ + gnu_u1 < sve_u1; /* { dg-error {invalid operands to binary <} } */ + gnu_u1 > sve_u1; /* { dg-error {invalid operands to binary >} } */ + gnu_u1 >= sve_u1; /* { dg-error {invalid operands to binary >=} } */ + gnu_u1 << sve_u1; /* { dg-error {invalid operands to binary <<} } */ + gnu_u1 >> sve_u1; /* { dg-error {invalid operands to binary >>} } */ + gnu_u1 && sve_u1; /* { dg-error {used vector type where scalar is required} } */ + gnu_u1 || sve_u1; /* { dg-error {used vector type where scalar is required} } */ + + gnu_u1 + gnu_u1; + gnu_u1 - gnu_u1; + gnu_u1 * gnu_u1; + gnu_u1 / gnu_u1; + gnu_u1 % gnu_u1; + gnu_u1 & gnu_u1; + gnu_u1 | gnu_u1; + gnu_u1 ^ gnu_u1; + gnu_u1 == gnu_u1; + gnu_u1 != gnu_u1; + gnu_u1 <= gnu_u1; + gnu_u1 < gnu_u1; + gnu_u1 > gnu_u1; + gnu_u1 >= gnu_u1; + gnu_u1 << gnu_u1; + gnu_u1 >> gnu_u1; + gnu_u1 && gnu_u1; /* { dg-error {used vector type where scalar is required} } */ + gnu_u1 || gnu_u1; /* { dg-error {used vector type where scalar is required} } */ + + /* Vector-scalar binary arithmetic. */ + + sve_u1 + 2; /* { dg-error {invalid operands to binary \+} } */ + sve_u1 - 2; /* { dg-error {invalid operands to binary -} } */ + sve_u1 * 2; /* { dg-error {invalid operands to binary \*} } */ + sve_u1 / 2; /* { dg-error {invalid operands to binary /} } */ + sve_u1 % 2; /* { dg-error {invalid operands to binary %} } */ + sve_u1 & 2; /* { dg-error {invalid operands to binary \&} } */ + sve_u1 | 2; /* { dg-error {invalid operands to binary \|} } */ + sve_u1 ^ 2; /* { dg-error {invalid operands to binary \^} } */ + sve_u1 == 2; /* { dg-error {invalid operands to binary ==} } */ + sve_u1 != 2; /* { dg-error {invalid operands to binary !=} } */ + sve_u1 <= 2; /* { dg-error {invalid operands to binary <=} } */ + sve_u1 < 2; /* { dg-error {invalid operands to binary <} } */ + sve_u1 > 2; /* { dg-error {invalid operands to binary >} } */ + sve_u1 >= 2; /* { dg-error {invalid operands to binary >=} } */ + sve_u1 << 2; /* { dg-error {invalid operands to binary <<} } */ + sve_u1 >> 2; /* { dg-error {invalid operands to binary >>} } */ + sve_u1 && 2; /* { dg-error {used vector type where scalar is required} } */ + sve_u1 || 2; /* { dg-error {used vector type where scalar is required} } */ + + sve_u1 + uc; /* { dg-error {invalid operands to binary \+} } */ + sve_u1 - uc; /* { dg-error {invalid operands to binary -} } */ + sve_u1 * uc; /* { dg-error {invalid operands to binary \*} } */ + sve_u1 / uc; /* { dg-error {invalid operands to binary /} } */ + sve_u1 % uc; /* { dg-error {invalid operands to binary %} } */ + sve_u1 & uc; /* { dg-error {invalid operands to binary \&} } */ + sve_u1 | uc; /* { dg-error {invalid operands to binary \|} } */ + sve_u1 ^ uc; /* { dg-error {invalid operands to binary \^} } */ + sve_u1 == uc; /* { dg-error {invalid operands to binary ==} } */ + sve_u1 != uc; /* { dg-error {invalid operands to binary !=} } */ + sve_u1 <= uc; /* { dg-error {invalid operands to binary <=} } */ + sve_u1 < uc; /* { dg-error {invalid operands to binary <} } */ + sve_u1 > uc; /* { dg-error {invalid operands to binary >} } */ + sve_u1 >= uc; /* { dg-error {invalid operands to binary >=} } */ + sve_u1 << uc; /* { dg-error {invalid operands to binary <<} } */ + sve_u1 >> uc; /* { dg-error {invalid operands to binary >>} } */ + sve_u1 && uc; /* { dg-error {used vector type where scalar is required} } */ + sve_u1 || uc; /* { dg-error {used vector type where scalar is required} } */ + + gnu_u1 + 2; + gnu_u1 - 2; + gnu_u1 * 2; + gnu_u1 / 2; + gnu_u1 % 2; + gnu_u1 & 2; + gnu_u1 | 2; + gnu_u1 ^ 2; + gnu_u1 == 2; + gnu_u1 != 2; + gnu_u1 <= 2; + gnu_u1 < 2; + gnu_u1 > 2; + gnu_u1 >= 2; + gnu_u1 << 2; + gnu_u1 >> 2; + gnu_u1 && 2; /* { dg-error {used vector type where scalar is required} } */ + gnu_u1 || 2; /* { dg-error {used vector type where scalar is required} } */ + + gnu_u1 + uc; + gnu_u1 - uc; + gnu_u1 * uc; + gnu_u1 / uc; + gnu_u1 % uc; + gnu_u1 & uc; + gnu_u1 | uc; + gnu_u1 ^ uc; + gnu_u1 == uc; + gnu_u1 != uc; + gnu_u1 <= uc; + gnu_u1 < uc; + gnu_u1 > uc; + gnu_u1 >= uc; + gnu_u1 << uc; + gnu_u1 >> uc; + gnu_u1 && uc; /* { dg-error {used vector type where scalar is required} } */ + gnu_u1 || uc; /* { dg-error {used vector type where scalar is required} } */ + + /* Scalar-vector binary arithmetic. */ + + 3 + sve_u1; /* { dg-error {invalid operands to binary \+} } */ + 3 - sve_u1; /* { dg-error {invalid operands to binary -} } */ + 3 * sve_u1; /* { dg-error {invalid operands to binary \*} } */ + 3 / sve_u1; /* { dg-error {invalid operands to binary /} } */ + 3 % sve_u1; /* { dg-error {invalid operands to binary %} } */ + 3 & sve_u1; /* { dg-error {invalid operands to binary \&} } */ + 3 | sve_u1; /* { dg-error {invalid operands to binary \|} } */ + 3 ^ sve_u1; /* { dg-error {invalid operands to binary \^} } */ + 3 == sve_u1; /* { dg-error {invalid operands to binary ==} } */ + 3 != sve_u1; /* { dg-error {invalid operands to binary !=} } */ + 3 <= sve_u1; /* { dg-error {invalid operands to binary <=} } */ + 3 < sve_u1; /* { dg-error {invalid operands to binary <} } */ + 3 > sve_u1; /* { dg-error {invalid operands to binary >} } */ + 3 >= sve_u1; /* { dg-error {invalid operands to binary >=} } */ + 3 << sve_u1; /* { dg-error {invalid operands to binary <<} } */ + 3 >> sve_u1; /* { dg-error {invalid operands to binary >>} } */ + 3 && sve_u1; /* { dg-error {invalid operands to binary \&\&} } */ + 3 || sve_u1; /* { dg-error {invalid operands to binary \|\|} } */ + + 3 + gnu_u1; + 3 - gnu_u1; + 3 * gnu_u1; + 3 / gnu_u1; + 3 % gnu_u1; + 3 & gnu_u1; + 3 | gnu_u1; + 3 ^ gnu_u1; + 3 == gnu_u1; + 3 != gnu_u1; + 3 <= gnu_u1; + 3 < gnu_u1; + 3 > gnu_u1; + 3 >= gnu_u1; + 3 << gnu_u1; + 3 >> gnu_u1; + 3 && gnu_u1; /* { dg-error {invalid operands to binary \&\&} } */ + 3 || gnu_u1; /* { dg-error {invalid operands to binary \|\|} } */ + + /* Mismatched types. */ + + sve_u1 + sve_s1; /* { dg-error {invalid operands to binary \+} } */ + sve_u1 - sve_s1; /* { dg-error {invalid operands to binary -} } */ + sve_u1 * sve_s1; /* { dg-error {invalid operands to binary \*} } */ + sve_u1 / sve_s1; /* { dg-error {invalid operands to binary /} } */ + sve_u1 % sve_s1; /* { dg-error {invalid operands to binary %} } */ + sve_u1 & sve_s1; /* { dg-error {invalid operands to binary \&} } */ + sve_u1 | sve_s1; /* { dg-error {invalid operands to binary \|} } */ + sve_u1 ^ sve_s1; /* { dg-error {invalid operands to binary \^} } */ + sve_u1 == sve_s1; /* { dg-error {invalid operands to binary ==} } */ + sve_u1 != sve_s1; /* { dg-error {invalid operands to binary !=} } */ + sve_u1 <= sve_s1; /* { dg-error {invalid operands to binary <=} } */ + sve_u1 < sve_s1; /* { dg-error {invalid operands to binary <} } */ + sve_u1 > sve_s1; /* { dg-error {invalid operands to binary >} } */ + sve_u1 >= sve_s1; /* { dg-error {invalid operands to binary >=} } */ + sve_u1 << sve_s1; /* { dg-error {invalid operands to binary <<} } */ + sve_u1 >> sve_s1; /* { dg-error {invalid operands to binary >>} } */ + sve_u1 && sve_s1; /* { dg-error {used vector type where scalar is required} } */ + sve_u1 || sve_s1; /* { dg-error {used vector type where scalar is required} } */ + + sve_u1 + gnu_s1; /* { dg-error {invalid operands to binary \+} } */ + sve_u1 - gnu_s1; /* { dg-error {invalid operands to binary -} } */ + sve_u1 * gnu_s1; /* { dg-error {invalid operands to binary \*} } */ + sve_u1 / gnu_s1; /* { dg-error {invalid operands to binary /} } */ + sve_u1 % gnu_s1; /* { dg-error {invalid operands to binary %} } */ + sve_u1 & gnu_s1; /* { dg-error {invalid operands to binary \&} } */ + sve_u1 | gnu_s1; /* { dg-error {invalid operands to binary \|} } */ + sve_u1 ^ gnu_s1; /* { dg-error {invalid operands to binary \^} } */ + sve_u1 == gnu_s1; /* { dg-error {invalid operands to binary ==} } */ + sve_u1 != gnu_s1; /* { dg-error {invalid operands to binary !=} } */ + sve_u1 <= gnu_s1; /* { dg-error {invalid operands to binary <=} } */ + sve_u1 < gnu_s1; /* { dg-error {invalid operands to binary <} } */ + sve_u1 > gnu_s1; /* { dg-error {invalid operands to binary >} } */ + sve_u1 >= gnu_s1; /* { dg-error {invalid operands to binary >=} } */ + sve_u1 << gnu_s1; /* { dg-error {invalid operands to binary <<} } */ + sve_u1 >> gnu_s1; /* { dg-error {invalid operands to binary >>} } */ + sve_u1 && gnu_s1; /* { dg-error {used vector type where scalar is required} } */ + sve_u1 || gnu_s1; /* { dg-error {used vector type where scalar is required} } */ + + gnu_u1 + sve_s1; /* { dg-error {invalid operands to binary \+} } */ + gnu_u1 - sve_s1; /* { dg-error {invalid operands to binary -} } */ + gnu_u1 * sve_s1; /* { dg-error {invalid operands to binary \*} } */ + gnu_u1 / sve_s1; /* { dg-error {invalid operands to binary /} } */ + gnu_u1 % sve_s1; /* { dg-error {invalid operands to binary %} } */ + gnu_u1 & sve_s1; /* { dg-error {invalid operands to binary \&} } */ + gnu_u1 | sve_s1; /* { dg-error {invalid operands to binary \|} } */ + gnu_u1 ^ sve_s1; /* { dg-error {invalid operands to binary \^} } */ + gnu_u1 == sve_s1; /* { dg-error {invalid operands to binary ==} } */ + gnu_u1 != sve_s1; /* { dg-error {invalid operands to binary !=} } */ + gnu_u1 <= sve_s1; /* { dg-error {invalid operands to binary <=} } */ + gnu_u1 < sve_s1; /* { dg-error {invalid operands to binary <} } */ + gnu_u1 > sve_s1; /* { dg-error {invalid operands to binary >} } */ + gnu_u1 >= sve_s1; /* { dg-error {invalid operands to binary >=} } */ + gnu_u1 << sve_s1; /* { dg-error {invalid operands to binary <<} } */ + gnu_u1 >> sve_s1; /* { dg-error {invalid operands to binary >>} } */ + gnu_u1 && sve_s1; /* { dg-error {used vector type where scalar is required} } */ + gnu_u1 || sve_s1; /* { dg-error {used vector type where scalar is required} } */ + + gnu_u1 + gnu_s1; + gnu_u1 - gnu_s1; + gnu_u1 * gnu_s1; + gnu_u1 / gnu_s1; + gnu_u1 % gnu_s1; + gnu_u1 & gnu_s1; + gnu_u1 | gnu_s1; + gnu_u1 ^ gnu_s1; + gnu_u1 == gnu_s1; + gnu_u1 != gnu_s1; + gnu_u1 <= gnu_s1; + gnu_u1 < gnu_s1; + gnu_u1 > gnu_s1; + gnu_u1 >= gnu_s1; + gnu_u1 << gnu_s1; + gnu_u1 >> gnu_s1; + gnu_u1 && gnu_s1; /* { dg-error {used vector type where scalar is required} } */ + gnu_u1 || gnu_s1; /* { dg-error {used vector type where scalar is required} } */ + + /* Conditional expressions. */ + + uc ? sve_u1 : sve_u1; + uc ? gnu_u1 : sve_u1; /* { dg-error {type mismatch in conditional expression} } */ + uc ? sve_u1 : gnu_u1; /* { dg-error {type mismatch in conditional expression} } */ + uc ? gnu_u1 : gnu_u1; + + sve_u1 ? sve_u1 : sve_u1; /* { dg-error {used vector type where scalar is required} } */ + sve_u1 ? gnu_u1 : sve_u1; /* { dg-error {used vector type where scalar is required} } */ + sve_u1 ? sve_u1 : gnu_u1; /* { dg-error {used vector type where scalar is required} } */ + sve_u1 ? gnu_u1 : gnu_u1; /* { dg-error {used vector type where scalar is required} } */ + + gnu_u1 ? sve_u1 : sve_u1; /* { dg-error {used vector type where scalar is required} } */ + gnu_u1 ? gnu_u1 : sve_u1; /* { dg-error {used vector type where scalar is required} } */ + gnu_u1 ? sve_u1 : gnu_u1; /* { dg-error {used vector type where scalar is required} } */ + gnu_u1 ? gnu_u1 : gnu_u1; /* { dg-error {used vector type where scalar is required} } */ + + /* Vector built-ins. */ + + __builtin_shuffle (sve_u1, sve_u1, sve_u1); /* { dg-error {'__builtin_shuffle' last argument must be an integer vector} } */ + __builtin_shuffle (sve_u1, gnu_u1, gnu_u1); /* { dg-error {'__builtin_shuffle' arguments must be vectors} } */ + __builtin_shuffle (gnu_u1, sve_u1, gnu_u1); /* { dg-error {'__builtin_shuffle' arguments must be vectors} } */ + __builtin_shuffle (gnu_u1, gnu_u1, sve_u1); /* { dg-error {'__builtin_shuffle' last argument must be an integer vector} } */ + __builtin_shuffle (gnu_u1, gnu_u1, gnu_u1); + + __builtin_convertvector (sve_u1, svuint8_t); /* { dg-error {'__builtin_convertvector' first argument must be an integer or floating vector} } */ + __builtin_convertvector (gnu_u1, svuint8_t); /* { dg-error {'__builtin_convertvector' second argument must be an integer or floating vector type} } */ + __builtin_convertvector (sve_u1, gnu_uint8_t); /* { dg-error {'__builtin_convertvector' first argument must be an integer or floating vector} } */ + __builtin_convertvector (gnu_u1, gnu_uint8_t); +} diff --git a/gcc/tree-core.h b/gcc/tree-core.h index cfd8839..12e0788 100644 --- a/gcc/tree-core.h +++ b/gcc/tree-core.h @@ -1628,7 +1628,8 @@ struct GTY(()) tree_type_common { unsigned warn_if_not_align : 6; unsigned typeless_storage : 1; unsigned empty_flag : 1; - unsigned spare : 17; + unsigned indivisible_p : 1; + unsigned spare : 16; alias_set_type alias_set; tree pointer_to; @@ -714,6 +714,11 @@ extern void omp_clause_range_check_failed (const_tree, const char *, int, /* Used to indicate that this TYPE represents a compiler-generated entity. */ #define TYPE_ARTIFICIAL(NODE) (TYPE_CHECK (NODE)->base.nowarning_flag) +/* True if the type is indivisible at the source level, i.e. if its + component parts cannot be accessed directly. This is used to suppress + normal GNU extensions for target-specific vector types. */ +#define TYPE_INDIVISIBLE_P(NODE) (TYPE_CHECK (NODE)->type_common.indivisible_p) + /* In an IDENTIFIER_NODE, this means that assemble_name was called with this string as an argument. */ #define TREE_SYMBOL_REFERENCED(NODE) \ |