https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110403
Bug ID: 110403
Summary: constant expression inside vector_size __attribute__
does not compile
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: janezz55 at gmail dot com
Target Milestone: ---
trying to compile:
template <typename T, std::size_t N>
using array_t __attribute__ ((vector_size(std::bit_ceil(N * sizeof(T))))) = T;
produces the following compile error:
error: 'vector_size' attribute argument value 'std::bit_ceil<long unsigned
int>((8 * sizeof (unsigned int)))' is not an integer constant
but without bit_ceil(), the following error may result:
error: number of vector components 3 not a power of two.
IMO, this is a bug, since N * sizeof(T) compiles without issue, but a call to a
constexpr function does not.
I have prepared an example:
https://wandbox.org/permlink/lGvFnhDCLJ05j1FM
The idea is to use a SIMD register instead of an array on the stack for
temporary storage.