Re: Did clang 14 lose some intrinsics support?

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Sun, 25 Sep 2022 20:46:47 UTC
On 25 Sep 2022, at 21:02, Jan Beich <jbeich@FreeBSD.org> wrote:
> 
> Christian Weisgerber <naddy@mips.inka.de> writes:
> 
>> Did we lose support for SSSE3 and AVX2 intrinsics on amd64 with
>> clang 14?
> 
> __builtin_* appear unstable unlike _mm* intrinsics. Clang 15 seems
> to hide more but I'm not sure about the cause (need bisecting).

Yeah, these internal names are constantly changing. I don't know the
reason for it, but it's terribly annoying when diagnosing failures with
preprocessed files, as these tend to break when compiled with a much
earlier or later copy of clang.


> ===> clang version 15.0.1
> #define SSE2_SUPPORTED 1
> #define SSE_SUPPORTED 1
> 
> ===> clang version 15.0.1 with -march=native
> #define AVX_SUPPORTED 1
> #define FMA_SUPPORTED 1
> #define SSE2_SUPPORTED 1
> #define SSE4_1_SUPPORTED 1
> #define SSE_SUPPORTED 1
> 
>> #if __has_builtin(__builtin_ia32_pabsd128)
>>  #define SSSE3_SUPPORTED 1
>> #endif
> [...]
>> #if __has_builtin(__builtin_ia32_pabsd256)
>>  #define AVX2_SUPPORTED 1
>> #endif
> 
> See https://github.com/llvm/llvm-project/commit/e5147f82e1cb
> 
> - Instead of __builtin_ia32_pabsd128 maybe use _mm_abs_epi32
> - Instead of __builtin_ia32_pabsd256 maybe use _mm256_abs_epi32
> 

I'm wondering why this rather fragile method is chosen? If you want to
know whether SSE is supported, you check for __SSE__, and similarly
__SSE2__, __AVX__ and a bunch of others. That is also portable to gcc.

-Dimitry