On 11/29/19 5:59 AM, Richard Sandiford wrote:
Ping
Richard Sandiford <richard.sandif...@arm.com> writes:
This is the C++ equivalent of r277950, which prevented the
use of the GNU vector extensions with SVE vector types for C.
[https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=277950].
I've copied the rationale below for reference.
The changes here are very similar to the C ones. Perhaps the only
noteworthy thing (that I know of) is that the patch continues to treat
!gnu_vector_type_p vector types as literal types/potential constexprs.
Disabling the GNU vector extensions shouldn't in itself stop the types
from being literal types, since whatever the target provides instead
might be constexpr material.
Tested on aarch64-linux-gnu and x86_64-linux-gnu. OK to install?
Richard
-------------------------------------------------------------------------
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.
-------------------------------------------------------------------------
2019-11-08 Richard Sandiford <richard.sandif...@arm.com>
gcc/cp/
* cp-tree.h (CP_AGGREGATE_TYPE_P): Check for gnu_vector_type_p
instead of VECTOR_TYPE.
* call.c (build_conditional_expr_1): Restrict vector handling
to vectors that satisfy gnu_vector_type_p. Don't treat the
"then" and "else" types as equivalent if they have the same
vector shape but differ in whether they're GNU vectors.
* cvt.c (ocp_convert): Only allow vectors to be converted
to bool if they satisfy gnu_vector_type_p.
(build_expr_type_conversion): Only allow conversions from
vectors if they satisfy gnu_vector_type_p.
* typeck.c (cp_build_binary_op): Only allow binary operators to be
applied to vectors if they satisfy gnu_vector_type_p.
(cp_build_unary_op): Likewise unary operators.
(build_reinterpret_cast_1):
Index: gcc/cp/call.c
===================================================================
--- gcc/cp/call.c 2019-11-08 08:31:19.000000000 +0000
+++ gcc/cp/call.c 2019-11-08 17:43:07.172264122 +0000
@@ -5397,6 +5401,7 @@ build_conditional_expr_1 (const op_locat
value category. */
if (((lvalue_p (arg2) && lvalue_p (arg3))
|| (xvalue_p (arg2) && xvalue_p (arg3)))
+ && gnu_vector_type_p (arg2_type) == gnu_vector_type_p (arg3_type)
&& same_type_p (arg2_type, arg3_type))
If the GNU-vector-ness differs, surely same_type_p should be false?
{
result_type = arg2_type;
@@ -5500,7 +5505,8 @@ build_conditional_expr_1 (const op_locat
--The second and third operands have the same type; the result is of
that type. */
- if (same_type_p (arg2_type, arg3_type))
+ if (gnu_vector_type_p (arg2_type) == gnu_vector_type_p (arg3_type)
+ && same_type_p (arg2_type, arg3_type))
Here too.
Jason