qt5base-lts/config.tests/x86_simd/main.cpp
Thiago Macieira db342f42a4 CMake: update the x86 intrinsic checks
Merge all the existing checks into a single one, which is a simple pass
or fail, since all our supported compilers support all the intrinsics up
to Cannon Lake. The two I've recently added (AVX512VBMI2 and VAES)
aren't yet supported everywhere, so they stay.

For some reason, all intrinsics seem to be disabled on Android. It looks
like some support was missing during the CMake port and this was never
again looked at. I'm leaving it be.

As for WASM, discussion with maintainers is that the WASM emulation of
x86 intrinsics is too hit-and-miss. No one is testing the performance,
particularly the person writing such code (me). They also have some
non-obvious selection of what is supported natively and what is
merely emulated. Using the actual WASM intrinsics is preferred, but
someone else's job.

Change-Id: Ib42b3adc93bf4d43bd55fffd16c10d66208e8384
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2022-06-28 03:28:42 +00:00

39 lines
1.1 KiB
C++

// Copyright (C) 2017 Intel Corporation.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
// All of our supported compilers support <immintrin.h>
#include <immintrin.h>
#define T(x) (QT_COMPILER_SUPPORTS_ ## x)
#if !defined(__INTEL_COMPILER) && !defined(_MSC_VER) && !defined(NO_ATTRIBUTE)
/* GCC requires attributes for a function */
# define attribute_target(x) __attribute__((__target__(x)))
#else
# define attribute_target(x)
#endif
#if T(AVX512VBMI2)
attribute_target("avx512vl,avx512vbmi2") void test_avx512vbmi2()
{
/* AVX512 Vector Byte Manipulation Instructions 2 */
__m128i a = _mm_maskz_compress_epi16(-1, _mm_set1_epi16(1));
__m128i b = _mm_shrdi_epi32(a, a, 7);
}
#endif
#if T(VAES)
// VAES does not require AVX512 and works on Alder Lake
attribute_target("avx2,vaes") void test_vaes()
{
/* 256- and 512-bit AES */
__m256i a = _mm256_set1_epi32(-1);
__m256i b = _mm256_aesenc_epi128(a, a);
__m256i c = _mm256_aesdec_epi128(b, a);
}
#endif
int main()
{
return 0;
}