[PATCH 2/2] libstdc++: Fix simd compilation with Clang

Jonathan Wakely jwakely@redhat.com
Tue Mar 21 11:19:35 GMT 2023


On Tue, 21 Mar 2023 at 09:24, Matthias Kretz via Libstdc++ <
libstdc++@gcc.gnu.org> wrote:

>
>
> Clang fails to compile some constant expressions involving simd.
> Therefore, just disable this non-conforming extension for clang.
>
> Fix AVX512 blend implementation for Clang. It was converting the bitmask
> to bool before, which is obviously wrong. Instead use a Clang builtin to
> convert the bitmask to vector-mask before using a vector blend ?:. A
> similar change is required for the masked unary implementation, because
> the GCC builtins do not exist on Clang.
>
> Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
>
> libstdc++-v3/ChangeLog:
>
>         * include/experimental/bits/simd_detail.h: Don't declare the
>         simd API as constexpr with Clang.
>         * include/experimental/bits/simd_x86.h (__movm): New.
>         (_S_blend_avx512): Resolve FIXME. Implement blend using __movm
>         and ?:.
>         (_SimdImplX86::_S_masked_unary): Clang does not implement the
>         same builtins. Implement the function using __movm, ?:, and -
>         operators on vector_size types instead.
>


+#if (defined __STRICT_ANSI__ && __STRICT_ANSI__) || defined __clang__

We don't generally are about -Wundef so this could be simplified to:

#if __STRICT_ANSI__ || defined __clang__

But it's OK as it is. OK for trunk.


More information about the Libstdc++ mailing list