From patchwork Thu Nov 7 10:45:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 1191064 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-512692-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="hhrdQi1K"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4780ST5H77z9sPT for ; Thu, 7 Nov 2019 21:46:17 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; q=dns; s=default; b=KN09bhWaoG2KFTwUvtbT8SjLGi7mu8Plrn7dXENfTZCwJxx19i UjUIqZdzxMIeGDu5207a6dSiAig2JolCutxq8M/9KKW995N45sm/LAuIQHEiIytc gRbLO6kjqPAgLmPSIpnpjFZMCBhgJtbnRvREzZOyHtn/b2xOWkK9f8eo8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; s= default; bh=JSmSvdV9PQ/ZwOMfrVjTDWdLIYk=; b=hhrdQi1KFbJ6Mg0Anxpw llBuZE7+NQ8bGY9ZSOMp7Jc7i6IzCev8Fitcjw4bYhKTu3yyk6tFe3grAamOeBoy bRJr+i7QT3crJHpj7/iCOBli8cKdZ78650S4aLAFrNWK5kwtFDk15MhJODw0u8KO MzzIhxd8twL7HEMxc8eDts4= Received: (qmail 74820 invoked by alias); 7 Nov 2019 10:46:03 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 74743 invoked by uid 89); 7 Nov 2019 10:45:59 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_STOCKGEN, SPF_PASS autolearn=ham version=3.3.1 spammy=tree.h, UD:tree.h, sk:c_type_, treeh X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.110.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 07 Nov 2019 10:45:43 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C275D30E; Thu, 7 Nov 2019 02:45:37 -0800 (PST) Received: from localhost (e121540-lin.manchester.arm.com [10.32.98.126]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CCC9D3F6C4; Thu, 7 Nov 2019 02:45:36 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, joseph@codesourcery.com, polacek@redhat.com, richard.sandiford@arm.com Cc: joseph@codesourcery.com, polacek@redhat.com Subject: [C] Opt out of GNU vector extensions for built-in SVE types Date: Thu, 07 Nov 2019 10:45:35 +0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes 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 intrinsics 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. I originally wrote this a series of patches that add one gnu_vector_type_p test each, along with the associated lines of the testcases. I wasn't sure in the end if it was useful to submit in that form though, so this is just a combined patch instead. I'm happy to post the individual patches if that would help. Tested on aarch64-linux-gnu and x86_64-linux-gnu. OK to install? Richard 2019-11-07 Richard Sandiford 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. Index: gcc/tree-core.h =================================================================== --- gcc/tree-core.h 2019-11-07 10:36:15.000000000 +0000 +++ gcc/tree-core.h 2019-11-07 10:36:15.597699502 +0000 @@ -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; Index: gcc/tree.h =================================================================== --- gcc/tree.h 2019-11-07 10:36:15.000000000 +0000 +++ gcc/tree.h 2019-11-07 10:36:15.597699502 +0000 @@ -714,6 +714,11 @@ #define TYPE_EMPTY_P(NODE) (TYPE_CHECK ( /* 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) \ Index: gcc/config/aarch64/aarch64-sve-builtins.cc =================================================================== --- gcc/config/aarch64/aarch64-sve-builtins.cc 2019-11-07 10:36:15.000000000 +0000 +++ gcc/config/aarch64/aarch64-sve-builtins.cc 2019-11-07 10:36:15.597699502 +0000 @@ -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); Index: gcc/c-family/c-common.h =================================================================== --- gcc/c-family/c-common.h 2019-11-07 10:36:15.000000000 +0000 +++ gcc/c-family/c-common.h 2019-11-07 10:36:15.593699530 +0000 @@ -757,6 +757,16 @@ #define C_TYPE_FUNCTION_P(type) \ #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. */ Index: gcc/c-family/c-common.c =================================================================== --- gcc/c-family/c-common.c 2019-11-07 10:36:15.000000000 +0000 +++ gcc/c-family/c-common.c 2019-11-07 10:36:15.593699530 +0000 @@ -1011,7 +1011,8 @@ c_build_vec_perm_expr (location_t loc, t || 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, t 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, tr 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, tr 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 (l 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 t 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 t 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); Index: gcc/c/c-convert.c =================================================================== --- gcc/c/c-convert.c 2019-11-07 10:36:15.000000000 +0000 +++ gcc/c/c-convert.c 2019-11-07 10:36:15.593699530 +0000 @@ -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: Index: gcc/c/c-typeck.c =================================================================== --- gcc/c/c-typeck.c 2019-11-07 10:36:15.000000000 +0000 +++ gcc/c/c-typeck.c 2019-11-07 10:36:15.597699502 +0000 @@ -2610,7 +2610,7 @@ build_array_ref (location_t loc, tree ar 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, enu 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, enu 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, enu 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, enu 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 t 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 imp 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 impl ; 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, st 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, st && 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, st && 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, st && 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, st 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, en /* 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, en 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, en 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, en 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, en 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, en 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, en 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, en 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, en 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, en 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, en 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, en } 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); Index: gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/gnu_vectors_1.c =================================================================== --- /dev/null 2019-09-17 11:41:18.176664108 +0100 +++ gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/gnu_vectors_1.c 2019-11-07 10:36:15.597699502 +0000 @@ -0,0 +1,415 @@ +/* { dg-options "-msve-vector-bits=256" } */ + +#include + +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); +} Index: gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/gnu_vectors_2.c =================================================================== --- /dev/null 2019-09-17 11:41:18.176664108 +0100 +++ gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/gnu_vectors_2.c 2019-11-07 10:36:15.597699502 +0000 @@ -0,0 +1,415 @@ +/* { dg-options "-msve-vector-bits=256 -flax-vector-conversions" } */ + +#include + +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); +}