[cfe-dev] [RFC] Opt-in vector of bool type
Richard Sandiford via cfe-dev
cfe-dev at lists.llvm.org
Thu May 14 09:23:07 PDT 2020
Simon Moll via cfe-dev <cfe-dev at lists.llvm.org> writes:
> We would like to extend Clang to allow 'bool' as a valid vector element
> type in C/C++ code for select targets.
> This is the natural type for SIMD masks and would facilitate clean SIMD
> intrinsic declarations in C/C++ code.
> Vectors of i1 are supported on IR level and below down to many SIMD
> ISAs, such as AVX512 or the VE target (NEC SX-Aurora TSUBASA).
> We understand the historical reasons for not supporting this (gcc
> However, this would be an opt-in feature and toolchains/targets that do
> not want this will be unaffected by the change.
> Looking forward to your feedback.
FWIW, this would also be useful for SVE predicates when generating
It's convenient that both GCC and clang reject boolean element types
as thing stand, e.g.:
typedef bool foo __attribute__((vector_size(32)));
I think this means that it should be possible to treat packed boolean
vectors as a pure extension to what exists today. Compatibility with
older compilers shouldn't be a concern, it would just be a new feature.
GCC is a moving target too, and I don't know of any reason in principle
why GCC would never support this. A lot of the necessary plumbing
So far the principle has been that vector_size should work the same
way regardless of the current target, with the compiler deciding
how best to implement the code. I think it would be good to follow
that for any extension too, rather than making the feature opt-in and
introducing a new target dependency.
More information about the cfe-dev