Re: Did clang 14 lose some intrinsics support?

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Mon, 26 Sep 2022 10:03:03 UTC
On 25 Sep 2022, at 23:38, Christian Weisgerber <naddy@mips.inka.de> wrote:
> 
> Dimitry Andric:
> 
>>> 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.
> 
> __AVX__, for instance, is not defined unless you compile with -mavx,
> which also allows the compiler to issue AVX instructions during
> normal code generation.

Sure, but if you are compiling without -mavx, why would you want the AVX
intrinsics? You cannot use AVX intrinsics anyway, if AVX is not enabled.

So I don't fully understand the problem this configure scripting is
supposed to solve?

In my opinion, if you would want to know whether the compiler supports
AVX in any mode, you would first attempt to run "$CC -mavx" and if that
succeeds, run a test case which checks for the __AVX__ define. If both
succeed, then AVX intrinsics work, otherwise they don't. Rinse and
repeat for any other particular extension you would want to check. And
should work for both clang and gcc.

-Dimitry