[Patch] OpenMP/C++: Fix 'construct={simd}' trait-selector handling with 'declare variant' [PR127734]
Jakub Jelinek
jakub@redhat.com
Sun Oct 11 10:13:06 GMT 2026
On Sun, Oct 11, 2026 at 09:50:04AM +0200, Tobias Burnus wrote:
> This patch fixes the handling
> #pragma omp declare variant(…) match( … construct={…,simd(…) … } )
> which was effectively ignored in C++ due to a
> 'return true;'
> after updating the 'simd' clauses.
>
> @Jakub: I guess, you also do not remember what's mean by both the FIXME
> and why there is a 'return true'? Or do you?
The intended behavior is that when simd isn't among the traits, we basically
take the arguments of the function and for the base look up (and instantiate
as needed) a function with the same argument types.
For simd, we should instead adjust the argument types depending on simdlen
and the chosen processor based on the Intel vector ABI (and other vector
ABIs derived from that one).
So, for declare variant without simd for function with int (int, long)
function type we look for function with int (int, long) time, while on
x86_64 if simdlen is 4 and it is notinbranch and it is the SSE2 case,
we should be looking up
int __attribute__((vector_size (4))) (int __attribute__((vector_size (4))),
long __attribute__((vector_size (2))),
long __attribute__((vector_size (2))))
function type instead (or instantiate it instead). So, basically look
at what function types we use when declare simd emits the specific variant
of the function, and look up the same argument types and compare the return
type.
So, using declare variant with simd is basically like doing manual
#pragma omp declare simd, user provides those functions instead of the
compiler though. And of course, it needs to be taken care of in the FEs
for the lookup and in the vectorizer too.
Jakub
More information about the Gcc-patches
mailing list