This is the mail archive of the
mailing list for the GCC project.
Re: Constexpr in intrinsics?
- From: Marc Glisse <marc dot glisse at inria dot fr>
- To: Allan Sandfeld Jensen <linux at carewolf dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Mon, 28 Mar 2016 11:02:08 +0200 (CEST)
- Subject: Re: Constexpr in intrinsics?
- Authentication-results: sourceware.org; auth=none
- References: <201603271216 dot 24068 dot linux at carewolf dot com> <alpine dot DEB dot 2 dot 20 dot 1603271243200 dot 8127 at laptop-mg dot saclay dot inria dot fr> <201603280234 dot 31374 dot linux at carewolf dot com>
- Reply-to: gcc at gcc dot gnu dot org
On Mon, 28 Mar 2016, Allan Sandfeld Jensen wrote:
On Sunday 27 March 2016, Marc Glisse wrote:
On Sun, 27 Mar 2016, Allan Sandfeld Jensen wrote:
Would it be possible to add constexpr to the intrinsics headers?
For instance _mm_set_XX and _mm_setzero intrinsics.
Already suggested here:
A patch would be welcome (I started doing it at some point, I don't
remember if it was functional, the patch is attached).
That looks very similar to the patch I experimented with, and that at least
works for using them in C++11 constexpr functions.
Ideally it could also be added all intrinsics that can be evaluated at
compile time, but it is harder to tell which those are.
Does gcc have a C extension we can use to set constexpr?
To have similar functionality in C. For instance to explicitly allow those
functions to be evaluated at compile time, and values with similar attributes
be optimized completely out.
Those intrinsics that are implemented without builtins can already be
evaluated at compile time.
return _mm_add_pd(a, b);
The generated asm is just
movapd .LC0(%rip), %xmm0
For the more esoteric intrinsics, what is missing is not in the parser, it
is a folder that understands the behavior of each particular intrinsic.
And of course avoid using precompiler noise, in
shared C/C++ headers like these are.