public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110403] New: constant expression inside vector_size __attribute__ does not compile
@ 2023-06-25 11:29 janezz55 at gmail dot com
2023-06-25 23:57 ` [Bug c++/110403] dependent function constexpr " janezz55 at gmail dot com
2023-06-26 13:45 ` ppalka at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: janezz55 at gmail dot com @ 2023-06-25 11:29 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/110403] dependent function constexpr inside vector_size __attribute__ does not compile
2023-06-25 11:29 [Bug c++/110403] New: constant expression inside vector_size __attribute__ does not compile janezz55 at gmail dot com
@ 2023-06-25 23:57 ` janezz55 at gmail dot com
2023-06-26 13:45 ` ppalka at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: janezz55 at gmail dot com @ 2023-06-25 23:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110403
--- Comment #1 from Janez Zemva <janezz55 at gmail dot com> ---
Here is a possible workaround:
#define S__(x) ((x) | (x) >> 1 | (x) >> 2 | (x) >> 3 | (x) >> 4)
#define BITCEIL(x) ((x) & (x) - 1 ? (S__(x) & ~(S__(x) >> 1)) << 1 : (x))
template <typename T, std::size_t N>
using array_t __attribute__ ((vector_size(BITCEIL(N * sizeof(T))))) = T;
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/110403] dependent function constexpr inside vector_size __attribute__ does not compile
2023-06-25 11:29 [Bug c++/110403] New: constant expression inside vector_size __attribute__ does not compile janezz55 at gmail dot com
2023-06-25 23:57 ` [Bug c++/110403] dependent function constexpr " janezz55 at gmail dot com
@ 2023-06-26 13:45 ` ppalka at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-06-26 13:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110403
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=105233
Ever confirmed|0 |1
CC| |ppalka at gcc dot gnu.org
Last reconfirmed| |2023-06-26
Status|UNCONFIRMED |NEW
--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Confirmed, closely related to PR105233 which was the same issue for the aligned
attribute (and alignas), and was fixed by performing manifestly constant
evaluation of their argument. I guess the same could be done for vector_size?
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-06-26 13:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-25 11:29 [Bug c++/110403] New: constant expression inside vector_size __attribute__ does not compile janezz55 at gmail dot com
2023-06-25 23:57 ` [Bug c++/110403] dependent function constexpr " janezz55 at gmail dot com
2023-06-26 13:45 ` ppalka at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).