[cfe-dev] [RFC] Opt-in vector of bool type

Finkel, Hal J. via cfe-dev cfe-dev at lists.llvm.org
Fri May 15 08:53:31 PDT 2020



________________________________
From: cfe-dev <cfe-dev-bounces at lists.llvm.org> on behalf of Keane, Erich via cfe-dev <cfe-dev at lists.llvm.org>
Sent: Friday, May 15, 2020 9:43 AM
To: Richard Sandiford <richard.sandiford at arm.com>; Keane, Erich via cfe-dev <cfe-dev at lists.llvm.org>
Cc: Erich Focht <Erich.Focht at EMEA.NEC.COM>; MARUKAWA KAZUSHI <marukawa at nec.com>; ISHIZAKA KAZUHISA <ishizaka at nec.com>
Subject: Re: [cfe-dev] [RFC] Opt-in vector of bool type

Right, I mentioned that:
> Note we don't allow taking a non-const ref or address of a vector element, but  GCC does, though presumably that is something we should fix.


I think that this is another thing that falls into the category of: only if we can define the semantics in a way that makes sense. For example, are the addresses of two adjacent vector elements adjacent? Can you do pointer arithmetic to get from one to the other?

 -Hal



-----Original Message-----
From: Richard Sandiford <richard.sandiford at arm.com>
Sent: Friday, May 15, 2020 7:41 AM
To: Keane, Erich via cfe-dev <cfe-dev at lists.llvm.org>
Cc: Simon Moll <Simon.Moll at EMEA.NEC.COM>; Craig Topper <craig.topper at gmail.com>; Keane, Erich <erich.keane at intel.com>; MARUKAWA KAZUSHI <marukawa at nec.com>; ISHIZAKA KAZUHISA <ishizaka at nec.com>; Erich Focht <Erich.Focht at EMEA.NEC.COM>
Subject: Re: [cfe-dev] [RFC] Opt-in vector of bool type

"Keane, Erich via cfe-dev" <cfe-dev at lists.llvm.org> writes:
>> The way i see it you are open to supporting this feature in Clang but there are LLVM bugs for <N x i1> types, which we may hit more often as a result, and then there is this unrelated Clang lvalue bug for attribute((vector_size)).
>
> I don't take this as a proper summary of my position. I was warning you about the issues in LLVM, however the biggest issue is the fact that a vector of i1s isn't individually addressable.  Unless you have a way to produce an address for each individual element (which we don't, and is why std::vector<bool> uses a proxy return type), I don't think this fits in the type system.

FWIW, I think taking the address of a vector_size element is already an error in clang.  E.g.

-----------------------------------------------------------------
typedef unsigned int vec __attribute__((vector_size(16))); vec v; unsigned int *foo(void) { return &v[1]; }
-----------------------------------------------------------------

gives:

-----------------------------------------------------------------
foo.c:3:34: error: address of vector element requested unsigned int *foo(void) { return &v[1]; }
                                 ^~~~~
1 error generated.
-----------------------------------------------------------------

GCC does accept this, but like others have said, I think the natural thing would be to make it an error for bools even if it isn't for other types.  The set of operations supported by a vector type is inevitably going to be influenced by the element type.

Definitely agree that the semantics need to be spelled out though. :-)

Thanks,
Richard
_______________________________________________
cfe-dev mailing list
cfe-dev at lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200515/31a47e5b/attachment-0001.html>


More information about the cfe-dev mailing list