https://github.com/markbhasawut updated https://github.com/llvm/llvm-project/pull/152910
>From e54e04113c97f9ebd877f45d39a5b1347d08d468 Mon Sep 17 00:00:00 2001 From: Bhasawut Singhaphan <bhasa...@gmail.com> Date: Thu, 7 Aug 2025 20:54:16 +0700 Subject: [PATCH 1/7] [Headers][X86] Allow AVX512 _mm512_set* intrinsics to be used in constexpr This PR adds constexpr support for the following AVX512F/BW/FP16 set intrinsics: - _mm512_set4_pd - _mm512_set4_ps - _mm512_set4_epi32 - _mm512_set4_epi64 - _mm512_set_pd - _mm512_set_ps - _mm512_set_epi8 - _mm512_set_epi16 - _mm512_set_epi32 - _mm512_set_epi64 - _mm512_setr_pd - _mm512_setr_ps - _mm512_setr_epi32 - _mm512_setr_epi64 - _mm512_set1_ph - _mm512_set_ph - _mm512_setr_ph - _mm_setzero_ph - _mm256_setzero_ph - _mm512_setzero_ph Closes https://github.com/llvm/llvm-project/issues/152288. Part of https://github.com/llvm/llvm-project/issues/30794. --- clang/lib/Headers/avx512fintrin.h | 94 +++++++++----------- clang/lib/Headers/avx512fp16intrin.h | 26 ++++-- clang/test/CodeGen/X86/avx512f-builtins.c | 14 ++- clang/test/CodeGen/X86/avx512fp16-builtins.c | 19 ++++ 4 files changed, 93 insertions(+), 60 deletions(-) diff --git a/clang/lib/Headers/avx512fintrin.h b/clang/lib/Headers/avx512fintrin.h index 940064675ba45..b3e9efdd519ab 100644 --- a/clang/lib/Headers/avx512fintrin.h +++ b/clang/lib/Headers/avx512fintrin.h @@ -351,32 +351,27 @@ _mm512_broadcastss_ps(__m128 __A) 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); } -static __inline __m512i __DEFAULT_FN_ATTRS512 -_mm512_set4_epi32 (int __A, int __B, int __C, int __D) -{ +static __inline __m512i __DEFAULT_FN_ATTRS512_CONSTEXPR +_mm512_set4_epi32(int __A, int __B, int __C, int __D) { return __extension__ (__m512i)(__v16si) { __D, __C, __B, __A, __D, __C, __B, __A, __D, __C, __B, __A, __D, __C, __B, __A }; } -static __inline __m512i __DEFAULT_FN_ATTRS512 -_mm512_set4_epi64 (long long __A, long long __B, long long __C, - long long __D) -{ +static __inline __m512i __DEFAULT_FN_ATTRS512_CONSTEXPR +_mm512_set4_epi64(long long __A, long long __B, long long __C, long long __D) { return __extension__ (__m512i) (__v8di) { __D, __C, __B, __A, __D, __C, __B, __A }; } -static __inline __m512d __DEFAULT_FN_ATTRS512 -_mm512_set4_pd (double __A, double __B, double __C, double __D) -{ +static __inline __m512d __DEFAULT_FN_ATTRS512_CONSTEXPR +_mm512_set4_pd(double __A, double __B, double __C, double __D) { return __extension__ (__m512d) { __D, __C, __B, __A, __D, __C, __B, __A }; } -static __inline __m512 __DEFAULT_FN_ATTRS512 -_mm512_set4_ps (float __A, float __B, float __C, float __D) -{ +static __inline __m512 __DEFAULT_FN_ATTRS512_CONSTEXPR +_mm512_set4_ps(float __A, float __B, float __C, float __D) { return __extension__ (__m512) { __D, __C, __B, __A, __D, __C, __B, __A, __D, __C, __B, __A, __D, __C, __B, __A }; @@ -9181,18 +9176,18 @@ _mm512_mask_set1_epi64 (__m512i __O, __mmask8 __M, long long __A) (__v8di) __O); } -static __inline __m512i __DEFAULT_FN_ATTRS512 -_mm512_set_epi8 (char __e63, char __e62, char __e61, char __e60, char __e59, - char __e58, char __e57, char __e56, char __e55, char __e54, char __e53, - char __e52, char __e51, char __e50, char __e49, char __e48, char __e47, - char __e46, char __e45, char __e44, char __e43, char __e42, char __e41, - char __e40, char __e39, char __e38, char __e37, char __e36, char __e35, - char __e34, char __e33, char __e32, char __e31, char __e30, char __e29, - char __e28, char __e27, char __e26, char __e25, char __e24, char __e23, - char __e22, char __e21, char __e20, char __e19, char __e18, char __e17, - char __e16, char __e15, char __e14, char __e13, char __e12, char __e11, - char __e10, char __e9, char __e8, char __e7, char __e6, char __e5, - char __e4, char __e3, char __e2, char __e1, char __e0) { +static __inline __m512i __DEFAULT_FN_ATTRS512_CONSTEXPR _mm512_set_epi8( + char __e63, char __e62, char __e61, char __e60, char __e59, char __e58, + char __e57, char __e56, char __e55, char __e54, char __e53, char __e52, + char __e51, char __e50, char __e49, char __e48, char __e47, char __e46, + char __e45, char __e44, char __e43, char __e42, char __e41, char __e40, + char __e39, char __e38, char __e37, char __e36, char __e35, char __e34, + char __e33, char __e32, char __e31, char __e30, char __e29, char __e28, + char __e27, char __e26, char __e25, char __e24, char __e23, char __e22, + char __e21, char __e20, char __e19, char __e18, char __e17, char __e16, + char __e15, char __e14, char __e13, char __e12, char __e11, char __e10, + char __e9, char __e8, char __e7, char __e6, char __e5, char __e4, char __e3, + char __e2, char __e1, char __e0) { return __extension__ (__m512i)(__v64qi) {__e0, __e1, __e2, __e3, __e4, __e5, __e6, __e7, @@ -9205,14 +9200,13 @@ _mm512_set_epi8 (char __e63, char __e62, char __e61, char __e60, char __e59, __e56, __e57, __e58, __e59, __e60, __e61, __e62, __e63}; } -static __inline __m512i __DEFAULT_FN_ATTRS512 -_mm512_set_epi16(short __e31, short __e30, short __e29, short __e28, - short __e27, short __e26, short __e25, short __e24, short __e23, - short __e22, short __e21, short __e20, short __e19, short __e18, - short __e17, short __e16, short __e15, short __e14, short __e13, - short __e12, short __e11, short __e10, short __e9, short __e8, - short __e7, short __e6, short __e5, short __e4, short __e3, - short __e2, short __e1, short __e0) { +static __inline __m512i __DEFAULT_FN_ATTRS512_CONSTEXPR _mm512_set_epi16( + short __e31, short __e30, short __e29, short __e28, short __e27, + short __e26, short __e25, short __e24, short __e23, short __e22, + short __e21, short __e20, short __e19, short __e18, short __e17, + short __e16, short __e15, short __e14, short __e13, short __e12, + short __e11, short __e10, short __e9, short __e8, short __e7, short __e6, + short __e5, short __e4, short __e3, short __e2, short __e1, short __e0) { return __extension__ (__m512i)(__v32hi) {__e0, __e1, __e2, __e3, __e4, __e5, __e6, __e7, __e8, __e9, __e10, __e11, __e12, __e13, __e14, __e15, @@ -9220,12 +9214,9 @@ _mm512_set_epi16(short __e31, short __e30, short __e29, short __e28, __e24, __e25, __e26, __e27, __e28, __e29, __e30, __e31 }; } -static __inline __m512i __DEFAULT_FN_ATTRS512 -_mm512_set_epi32 (int __A, int __B, int __C, int __D, - int __E, int __F, int __G, int __H, - int __I, int __J, int __K, int __L, - int __M, int __N, int __O, int __P) -{ +static __inline __m512i __DEFAULT_FN_ATTRS512_CONSTEXPR _mm512_set_epi32( + int __A, int __B, int __C, int __D, int __E, int __F, int __G, int __H, + int __I, int __J, int __K, int __L, int __M, int __N, int __O, int __P) { return __extension__ (__m512i)(__v16si) { __P, __O, __N, __M, __L, __K, __J, __I, __H, __G, __F, __E, __D, __C, __B, __A }; @@ -9236,11 +9227,9 @@ _mm512_set_epi32 (int __A, int __B, int __C, int __D, _mm512_set_epi32((e15),(e14),(e13),(e12),(e11),(e10),(e9),(e8),(e7),(e6), \ (e5),(e4),(e3),(e2),(e1),(e0)) -static __inline__ __m512i __DEFAULT_FN_ATTRS512 -_mm512_set_epi64 (long long __A, long long __B, long long __C, - long long __D, long long __E, long long __F, - long long __G, long long __H) -{ +static __inline__ __m512i __DEFAULT_FN_ATTRS512_CONSTEXPR +_mm512_set_epi64(long long __A, long long __B, long long __C, long long __D, + long long __E, long long __F, long long __G, long long __H) { return __extension__ (__m512i) (__v8di) { __H, __G, __F, __E, __D, __C, __B, __A }; } @@ -9248,10 +9237,9 @@ _mm512_set_epi64 (long long __A, long long __B, long long __C, #define _mm512_setr_epi64(e0,e1,e2,e3,e4,e5,e6,e7) \ _mm512_set_epi64((e7),(e6),(e5),(e4),(e3),(e2),(e1),(e0)) -static __inline__ __m512d __DEFAULT_FN_ATTRS512 -_mm512_set_pd (double __A, double __B, double __C, double __D, - double __E, double __F, double __G, double __H) -{ +static __inline__ __m512d __DEFAULT_FN_ATTRS512_CONSTEXPR +_mm512_set_pd(double __A, double __B, double __C, double __D, double __E, + double __F, double __G, double __H) { return __extension__ (__m512d) { __H, __G, __F, __E, __D, __C, __B, __A }; } @@ -9259,12 +9247,10 @@ _mm512_set_pd (double __A, double __B, double __C, double __D, #define _mm512_setr_pd(e0,e1,e2,e3,e4,e5,e6,e7) \ _mm512_set_pd((e7),(e6),(e5),(e4),(e3),(e2),(e1),(e0)) -static __inline__ __m512 __DEFAULT_FN_ATTRS512 -_mm512_set_ps (float __A, float __B, float __C, float __D, - float __E, float __F, float __G, float __H, - float __I, float __J, float __K, float __L, - float __M, float __N, float __O, float __P) -{ +static __inline__ __m512 __DEFAULT_FN_ATTRS512_CONSTEXPR +_mm512_set_ps(float __A, float __B, float __C, float __D, float __E, float __F, + float __G, float __H, float __I, float __J, float __K, float __L, + float __M, float __N, float __O, float __P) { return __extension__ (__m512) { __P, __O, __N, __M, __L, __K, __J, __I, __H, __G, __F, __E, __D, __C, __B, __A }; diff --git a/clang/lib/Headers/avx512fp16intrin.h b/clang/lib/Headers/avx512fp16intrin.h index 92df320b45006..e1b198b7fc5c9 100644 --- a/clang/lib/Headers/avx512fp16intrin.h +++ b/clang/lib/Headers/avx512fp16intrin.h @@ -33,15 +33,26 @@ typedef _Float16 __m512h_u __attribute__((__vector_size__(64), __aligned__(1))); __target__("avx512fp16,no-evex512"), \ __min_vector_width__(128))) +#if defined(__cplusplus) && (__cplusplus >= 201103L) +#define __DEFAULT_FN_ATTRS512_CONSTEXPR __DEFAULT_FN_ATTRS512 constexpr +#define __DEFAULT_FN_ATTRS256_CONSTEXPR __DEFAULT_FN_ATTRS256 constexpr +#define __DEFAULT_FN_ATTRS128_CONSTEXPR __DEFAULT_FN_ATTRS128 constexpr +#else +#define __DEFAULT_FN_ATTRS512_CONSTEXPR __DEFAULT_FN_ATTRS512 +#define __DEFAULT_FN_ATTRS256_CONSTEXPR __DEFAULT_FN_ATTRS256 +#define __DEFAULT_FN_ATTRS128_CONSTEXPR __DEFAULT_FN_ATTRS128 +#endif + static __inline__ _Float16 __DEFAULT_FN_ATTRS512 _mm512_cvtsh_h(__m512h __a) { return __a[0]; } -static __inline __m128h __DEFAULT_FN_ATTRS128 _mm_setzero_ph(void) { +static __inline __m128h __DEFAULT_FN_ATTRS128_CONSTEXPR _mm_setzero_ph(void) { return (__m128h){0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; } -static __inline __m256h __DEFAULT_FN_ATTRS256 _mm256_setzero_ph(void) { +static __inline __m256h __DEFAULT_FN_ATTRS256_CONSTEXPR +_mm256_setzero_ph(void) { return (__m256h){0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; } @@ -50,7 +61,8 @@ static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_undefined_ph(void) { return (__m256h)__builtin_ia32_undef256(); } -static __inline __m512h __DEFAULT_FN_ATTRS512 _mm512_setzero_ph(void) { +static __inline __m512h __DEFAULT_FN_ATTRS512_CONSTEXPR +_mm512_setzero_ph(void) { return (__m512h){0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; @@ -64,14 +76,15 @@ static __inline__ __m512h __DEFAULT_FN_ATTRS512 _mm512_undefined_ph(void) { return (__m512h)__builtin_ia32_undef512(); } -static __inline __m512h __DEFAULT_FN_ATTRS512 _mm512_set1_ph(_Float16 __h) { +static __inline __m512h __DEFAULT_FN_ATTRS512_CONSTEXPR +_mm512_set1_ph(_Float16 __h) { return (__m512h)(__v32hf){__h, __h, __h, __h, __h, __h, __h, __h, __h, __h, __h, __h, __h, __h, __h, __h, __h, __h, __h, __h, __h, __h, __h, __h, __h, __h, __h, __h, __h, __h, __h, __h}; } -static __inline __m512h __DEFAULT_FN_ATTRS512 +static __inline __m512h __DEFAULT_FN_ATTRS512_CONSTEXPR _mm512_set_ph(_Float16 __h1, _Float16 __h2, _Float16 __h3, _Float16 __h4, _Float16 __h5, _Float16 __h6, _Float16 __h7, _Float16 __h8, _Float16 __h9, _Float16 __h10, _Float16 __h11, _Float16 __h12, @@ -3348,6 +3361,9 @@ _mm512_permutexvar_ph(__m512i __A, __m512h __B) { #undef __DEFAULT_FN_ATTRS128 #undef __DEFAULT_FN_ATTRS256 #undef __DEFAULT_FN_ATTRS512 +#undef __DEFAULT_FN_ATTRS128_CONSTEXPR +#undef __DEFAULT_FN_ATTRS256_CONSTEXPR +#undef __DEFAULT_FN_ATTRS512_CONSTEXPR #endif #endif diff --git a/clang/test/CodeGen/X86/avx512f-builtins.c b/clang/test/CodeGen/X86/avx512f-builtins.c index 26bf5fa9766d7..2a8daa79f9510 100644 --- a/clang/test/CodeGen/X86/avx512f-builtins.c +++ b/clang/test/CodeGen/X86/avx512f-builtins.c @@ -10296,6 +10296,9 @@ __m512i test_mm512_set_epi8(char e63, char e62, char e61, char e60, char e59, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0); } +TEST_CONSTEXPR(match_v64qi(_mm512_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63), 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63)); __m512i test_mm512_set_epi16(short e31, short e30, short e29, short e28, short e27, short e26, short e25, short e24, short e23, short e22, @@ -10339,8 +10342,9 @@ __m512i test_mm512_set_epi16(short e31, short e30, short e29, short e28, return _mm512_set_epi16(e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0); - } +TEST_CONSTEXPR(match_v32hi(_mm512_set_epi16(0, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20, -21, 22, -23, 24, -25, 26, -27, 28, -29, 30, -31), 0, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20, -21, 22, -23, 24, -25, 26, -27, 28, -29, 30, -31)); + __m512i test_mm512_set_epi32 (int __A, int __B, int __C, int __D, int __E, int __F, int __G, int __H, int __I, int __J, int __K, int __L, @@ -10366,6 +10370,7 @@ __m512i test_mm512_set_epi32 (int __A, int __B, int __C, int __D, return _mm512_set_epi32( __A, __B, __C, __D,__E, __F, __G, __H, __I, __J, __K, __L,__M, __N, __O, __P); } +TEST_CONSTEXPR(match_v16si(_mm512_set_epi32(0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15), 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15)); __m512i test_mm512_setr_epi32 (int __A, int __B, int __C, int __D, int __E, int __F, int __G, int __H, @@ -10408,6 +10413,7 @@ __m512i test_mm512_setr_epi32 (int __A, int __B, int __C, int __D, return _mm512_setr_epi32( __A, __B, __C, __D,__E, __F, __G, __H, __I, __J, __K, __L,__M, __N, __O, __P); } +TEST_CONSTEXPR(match_v16si(_mm512_setr_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15), 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)); __m512i test_mm512_mask_set1_epi64 (__m512i __O, __mmask8 __M, long long __A) { @@ -10455,6 +10461,7 @@ __m512i test_mm512_set_epi64 (long long __A, long long __B, long long __C, //CHECK: insertelement{{.*}}i32 7 return _mm512_set_epi64(__A, __B, __C, __D, __E, __F, __G, __H ); } +TEST_CONSTEXPR(match_v8di(_mm512_set_epi64(1, -3, 5, -7, 9, -11, 13, -15), 1, -3, 5, -7, 9, -11, 13, -15)); __m512i test_mm512_setr_epi64 (long long __A, long long __B, long long __C, long long __D, long long __E, long long __F, @@ -10479,6 +10486,7 @@ __m512i test_mm512_setr_epi64 (long long __A, long long __B, long long __C, //CHECK: insertelement{{.*}}i32 7 return _mm512_setr_epi64(__A, __B, __C, __D, __E, __F, __G, __H ); } +TEST_CONSTEXPR(match_v8di(_mm512_setr_epi64(-1, 3, -5, 7, -9, 11, -13, 15), -1, 3, -5, 7, -9, 11, -13, 15)); __m512d test_mm512_set_pd (double __A, double __B, double __C, double __D, double __E, double __F, double __G, double __H) @@ -10494,6 +10502,7 @@ __m512d test_mm512_set_pd (double __A, double __B, double __C, double __D, //CHECK: insertelement{{.*}}i32 7 return _mm512_set_pd( __A, __B, __C, __D, __E, __F, __G, __H); } +TEST_CONSTEXPR(match_m512d(_mm512_set_pd(200, 400, 600, 800, 1000, 1200, 1400, 1600), 200, 400, 600, 800, 1000, 1200, 1400, 1600)); __m512d test_mm512_setr_pd (double __A, double __B, double __C, double __D, double __E, double __F, double __G, double __H) @@ -10517,6 +10526,7 @@ __m512d test_mm512_setr_pd (double __A, double __B, double __C, double __D, //CHECK: insertelement{{.*}}i32 7 return _mm512_setr_pd( __A, __B, __C, __D, __E, __F, __G, __H); } +TEST_CONSTEXPR(match_m512d(_mm512_setr_pd(-20, 40, -60, 80, -100, 120, -140, 160), -20, 40, -60, 80, -100, 120, -140, 160)); __m512 test_mm512_set_ps (float __A, float __B, float __C, float __D, float __E, float __F, float __G, float __H, @@ -10543,6 +10553,7 @@ __m512 test_mm512_set_ps (float __A, float __B, float __C, float __D, return _mm512_set_ps( __A, __B, __C, __D, __E, __F, __G, __H, __I, __J, __K, __L, __M, __N, __O, __P); } +TEST_CONSTEXPR(match_m512(_mm512_set_ps(1.0f, -2.0f, 3.0f, -4.0f, 5.0f, -6.0f, 7.0f, -8.0f, 9.0f, -10.0f, 11.0f, -12.0f, 13.0f, -14.0f, 15.0f, -16.0f), 1.0f, -2.0f, 3.0f, -4.0f, 5.0f, -6.0f, 7.0f, -8.0f, 9.0f, -10.0f, 11.0f, -12.0f, 13.0f, -14.0f, 15.0f, -16.0f)); __m512i test_mm512_mask_abs_epi64 (__m512i __W, __mmask8 __U, __m512i __A) { @@ -10621,6 +10632,7 @@ __m512 test_mm512_setr_ps (float __A, float __B, float __C, float __D, return _mm512_setr_ps( __A, __B, __C, __D, __E, __F, __G, __H, __I, __J, __K, __L, __M, __N, __O, __P); } +TEST_CONSTEXPR(match_m512(_mm512_setr_ps(-1.0f, 2.0f, -3.0f, 4.0f, -5.0f, 6.0f, -7.0f, 8.0f, -9.0f, 10.0f, -11.0f, 12.0f, -13.0f, 14.0f, -15.0f, 16.0f), -1.0f, 2.0f, -3.0f, 4.0f, -5.0f, 6.0f, -7.0f, 8.0f, -9.0f, 10.0f, -11.0f, 12.0f, -13.0f, 14.0f, -15.0f, 16.0f)); int test_mm_cvtss_i32(__m128 A) { // CHECK-LABEL: test_mm_cvtss_i32 diff --git a/clang/test/CodeGen/X86/avx512fp16-builtins.c b/clang/test/CodeGen/X86/avx512fp16-builtins.c index d7ac2c94be62d..ab170656c4480 100644 --- a/clang/test/CodeGen/X86/avx512fp16-builtins.c +++ b/clang/test/CodeGen/X86/avx512fp16-builtins.c @@ -16,12 +16,14 @@ __m128h test_mm_setzero_ph(void) { // CHECK: zeroinitializer return _mm_setzero_ph(); } +TEST_CONSTEXPR(match_m128(_mm_setzero_ph(), +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f)); __m256h test_mm256_setzero_ph(void) { // CHECK-LABEL: test_mm256_setzero_ph // CHECK: zeroinitializer return _mm256_setzero_ph(); } +TEST_CONSTEXPR(match_m256(_mm256_setzero_ph(), +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f)); __m256h test_mm256_undefined_ph(void) { // CHECK-LABEL: test_mm256_undefined_ph @@ -34,6 +36,7 @@ __m512h test_mm512_setzero_ph(void) { // CHECK: zeroinitializer return _mm512_setzero_ph(); } +TEST_CONSTEXPR(match_m512(_mm512_setzero_ph(), +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f)); __m128h test_mm_undefined_ph(void) { // CHECK-LABEL: test_mm_undefined_ph @@ -83,6 +86,7 @@ __m512h test_mm512_set1_ph(_Float16 h) { // CHECK: insertelement <32 x half> {{.*}}, i32 31 return _mm512_set1_ph(h); } +TEST_CONSTEXPR(match_m512(_mm512_set1_ph(-101.0f), -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f)); __m512h test_mm512_set1_pch(_Float16 _Complex h) { // CHECK-LABEL: test_mm512_set1_pch @@ -152,6 +156,13 @@ __m512h test_mm512_set_ph(_Float16 __h1, _Float16 __h2, _Float16 __h3, _Float16 __h17, __h18, __h19, __h20, __h21, __h22, __h23, __h24, __h25, __h26, __h27, __h28, __h29, __h30, __h31, __h32); } +TEST_CONSTEXPR(match_mm512(_mm512_set_ph(-1.0f, 2.0f, -3.0f, 4.0f, -5.0f, 6.0f, -7.0f, 8.0f, + -9.0f, 10.0f, -11.0f, 12.0f, -13.0f, 14.0f, -15.0f, 16.0f, + -17.0f, 18.0f, -19.0f, 20.0f, -21.0f, 22.0f, -23.0f, 24.0f, + -25.0f, 26.0f, -27.0f, 28.0f, -29.0f, 30.0f, -31.0f, 32.0f), -1.0f, 2.0f, -3.0f, 4.0f, -5.0f, 6.0f, -7.0f, 8.0f, + -9.0f, 10.0f, -11.0f, 12.0f, -13.0f, 14.0f, -15.0f, 16.0f, + -17.0f, 18.0f, -19.0f, 20.0f, -21.0f, 22.0f, -23.0f, 24.0f, + -25.0f, 26.0f, -27.0f, 28.0f, -29.0f, 30.0f, -31.0f, 32.0f)); __m512h test_mm512_setr_ph(_Float16 __h1, _Float16 __h2, _Float16 __h3, _Float16 __h4, _Float16 __h5, _Float16 __h6, _Float16 __h7, _Float16 __h8, @@ -199,6 +210,14 @@ __m512h test_mm512_setr_ph(_Float16 __h1, _Float16 __h2, _Float16 __h3, _Float16 __h17, __h18, __h19, __h20, __h21, __h22, __h23, __h24, __h25, __h26, __h27, __h28, __h29, __h30, __h31, __h32); } +TEST_CONSTEXPR(match_mm512(_mm512_setr_ph(1.0f, -3.0f, 5.0f, -7.0f, 9.0f, -11.0f, 13.0f, -15.0f, + 17.0f, -19.0f, 21.0f, -23.0f, 25.0f, -27.0f, 29.0f, -31.0f, + 33.0f, -35.0f, 37.0f, -39.0f, 41.0f, -43.0f, 45.0f, -47.0f, + 49.0f, -51.0f, 53.0f, -55.0f, 57.0f, -59.0f, 61.0f, -63.0f), + 1.0f, -3.0f, 5.0f, -7.0f, 9.0f, -11.0f, 13.0f, -15.0f, + 17.0f, -19.0f, 21.0f, -23.0f, 25.0f, -27.0f, 29.0f, -31.0f, + 33.0f, -35.0f, 37.0f, -39.0f, 41.0f, -43.0f, 45.0f, -47.0f, + 49.0f, -51.0f, 53.0f, -55.0f, 57.0f, -59.0f, 61.0f, -63.0f)); __m128 test_mm_castph_ps(__m128h A) { // CHECK-LABEL: test_mm_castph_ps >From c5522073fe30fb54acb1d8ac76057c0c99cfceab Mon Sep 17 00:00:00 2001 From: Bhasawut Singhaphan <bhasa...@gmail.com> Date: Sun, 10 Aug 2025 20:56:42 +0700 Subject: [PATCH 2/7] Add missing builtin_test_helpers header --- clang/test/CodeGen/X86/avx512fp16-builtins.c | 1 + 1 file changed, 1 insertion(+) diff --git a/clang/test/CodeGen/X86/avx512fp16-builtins.c b/clang/test/CodeGen/X86/avx512fp16-builtins.c index ab170656c4480..e52610af16c63 100644 --- a/clang/test/CodeGen/X86/avx512fp16-builtins.c +++ b/clang/test/CodeGen/X86/avx512fp16-builtins.c @@ -4,6 +4,7 @@ // RUN: %clang_cc1 -x c++ -ffreestanding -flax-vector-conversions=none %s -triple=i686-unknown-unknown -target-feature +avx512fp16 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK #include <immintrin.h> +#include "builtin_test_helpers.h" _Float16 test_mm512_cvtsh_h(__m512h __A) { // CHECK-LABEL: test_mm512_cvtsh_h >From 9338627cd383427cafb9b49be5c8b03dd9e7586b Mon Sep 17 00:00:00 2001 From: Bhasawut Singhaphan <bhasa...@gmail.com> Date: Mon, 11 Aug 2025 01:09:31 +0700 Subject: [PATCH 3/7] Update test cases to use double precision --- clang/test/CodeGen/X86/avx512f-builtins.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/test/CodeGen/X86/avx512f-builtins.c b/clang/test/CodeGen/X86/avx512f-builtins.c index 2a8daa79f9510..3a47df617d5f0 100644 --- a/clang/test/CodeGen/X86/avx512f-builtins.c +++ b/clang/test/CodeGen/X86/avx512f-builtins.c @@ -10502,7 +10502,7 @@ __m512d test_mm512_set_pd (double __A, double __B, double __C, double __D, //CHECK: insertelement{{.*}}i32 7 return _mm512_set_pd( __A, __B, __C, __D, __E, __F, __G, __H); } -TEST_CONSTEXPR(match_m512d(_mm512_set_pd(200, 400, 600, 800, 1000, 1200, 1400, 1600), 200, 400, 600, 800, 1000, 1200, 1400, 1600)); +TEST_CONSTEXPR(match_m512d(_mm512_set_pd(20.0, 40.0, 60.0, 80.0, 100.0, 120.0, 140.0, 160.0), 20.0, 40.0, 60.0, 80.0, 100.0, 120.0, 140.0, 160.0)); __m512d test_mm512_setr_pd (double __A, double __B, double __C, double __D, double __E, double __F, double __G, double __H) @@ -10526,7 +10526,7 @@ __m512d test_mm512_setr_pd (double __A, double __B, double __C, double __D, //CHECK: insertelement{{.*}}i32 7 return _mm512_setr_pd( __A, __B, __C, __D, __E, __F, __G, __H); } -TEST_CONSTEXPR(match_m512d(_mm512_setr_pd(-20, 40, -60, 80, -100, 120, -140, 160), -20, 40, -60, 80, -100, 120, -140, 160)); +TEST_CONSTEXPR(match_m512d(_mm512_setr_pd(-20.0, 40.0, -60.0, 80.0, -100.0, 120.0, -140.0, 160.0), -20.0, 40.0, -60.0, 80.0, -100.0, 120.0, -140.0, 160.0)); __m512 test_mm512_set_ps (float __A, float __B, float __C, float __D, float __E, float __F, float __G, float __H, >From 4fd2cce8b8c47093916e5d6bf445b53c1eab5049 Mon Sep 17 00:00:00 2001 From: Bhasawut Singhaphan <bhasa...@gmail.com> Date: Mon, 11 Aug 2025 03:28:22 +0700 Subject: [PATCH 4/7] Fix incorrect test cases --- clang/test/CodeGen/X86/avx512f-builtins.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/clang/test/CodeGen/X86/avx512f-builtins.c b/clang/test/CodeGen/X86/avx512f-builtins.c index 3a47df617d5f0..1ce4bf1985e6f 100644 --- a/clang/test/CodeGen/X86/avx512f-builtins.c +++ b/clang/test/CodeGen/X86/avx512f-builtins.c @@ -10296,8 +10296,10 @@ __m512i test_mm512_set_epi8(char e63, char e62, char e61, char e60, char e59, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0); } -TEST_CONSTEXPR(match_v64qi(_mm512_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63), 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, +TEST_CONSTEXPR(match_v64qi(_mm512_set_epi8(63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, + 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, + 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0), 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63)); __m512i test_mm512_set_epi16(short e31, short e30, short e29, short e28, @@ -10343,7 +10345,7 @@ __m512i test_mm512_set_epi16(short e31, short e30, short e29, short e28, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0); } -TEST_CONSTEXPR(match_v32hi(_mm512_set_epi16(0, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20, -21, 22, -23, 24, -25, 26, -27, 28, -29, 30, -31), 0, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20, -21, 22, -23, 24, -25, 26, -27, 28, -29, 30, -31)); +TEST_CONSTEXPR(match_v32hi(_mm512_set_epi16(-31, 30, -29, 28, -27, 26, -25, 24, -23, 22, -21, 20, -19, 18, -17, 16, -15, 14, -13, 12, -11, 10, -9, 8, -7, 6, -5, 4, -3, 2, -1, 0), 0, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20, -21, 22, -23, 24, -25, 26, -27, 28, -29, 30, -31)); __m512i test_mm512_set_epi32 (int __A, int __B, int __C, int __D, int __E, int __F, int __G, int __H, @@ -10370,7 +10372,7 @@ __m512i test_mm512_set_epi32 (int __A, int __B, int __C, int __D, return _mm512_set_epi32( __A, __B, __C, __D,__E, __F, __G, __H, __I, __J, __K, __L,__M, __N, __O, __P); } -TEST_CONSTEXPR(match_v16si(_mm512_set_epi32(0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15), 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15)); +TEST_CONSTEXPR(match_v16si(_mm512_set_epi32(-15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0), 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15)); __m512i test_mm512_setr_epi32 (int __A, int __B, int __C, int __D, int __E, int __F, int __G, int __H, @@ -10461,7 +10463,7 @@ __m512i test_mm512_set_epi64 (long long __A, long long __B, long long __C, //CHECK: insertelement{{.*}}i32 7 return _mm512_set_epi64(__A, __B, __C, __D, __E, __F, __G, __H ); } -TEST_CONSTEXPR(match_v8di(_mm512_set_epi64(1, -3, 5, -7, 9, -11, 13, -15), 1, -3, 5, -7, 9, -11, 13, -15)); +TEST_CONSTEXPR(match_v8di(_mm512_set_epi64(-15, 13, -11, 9, -7, 5, -3, 1), 1, -3, 5, -7, 9, -11, 13, -15)); __m512i test_mm512_setr_epi64 (long long __A, long long __B, long long __C, long long __D, long long __E, long long __F, @@ -10502,7 +10504,7 @@ __m512d test_mm512_set_pd (double __A, double __B, double __C, double __D, //CHECK: insertelement{{.*}}i32 7 return _mm512_set_pd( __A, __B, __C, __D, __E, __F, __G, __H); } -TEST_CONSTEXPR(match_m512d(_mm512_set_pd(20.0, 40.0, 60.0, 80.0, 100.0, 120.0, 140.0, 160.0), 20.0, 40.0, 60.0, 80.0, 100.0, 120.0, 140.0, 160.0)); +TEST_CONSTEXPR(match_m512d(_mm512_set_pd(20.0, 40.0, 60.0, 80.0, 100.0, 120.0, 140.0, 160.0), 160.0, 140.0, 120.0, 100.0, 80.0, 60.0, 40.0, 20.0)); __m512d test_mm512_setr_pd (double __A, double __B, double __C, double __D, double __E, double __F, double __G, double __H) @@ -10553,7 +10555,7 @@ __m512 test_mm512_set_ps (float __A, float __B, float __C, float __D, return _mm512_set_ps( __A, __B, __C, __D, __E, __F, __G, __H, __I, __J, __K, __L, __M, __N, __O, __P); } -TEST_CONSTEXPR(match_m512(_mm512_set_ps(1.0f, -2.0f, 3.0f, -4.0f, 5.0f, -6.0f, 7.0f, -8.0f, 9.0f, -10.0f, 11.0f, -12.0f, 13.0f, -14.0f, 15.0f, -16.0f), 1.0f, -2.0f, 3.0f, -4.0f, 5.0f, -6.0f, 7.0f, -8.0f, 9.0f, -10.0f, 11.0f, -12.0f, 13.0f, -14.0f, 15.0f, -16.0f)); +TEST_CONSTEXPR(match_m512(_mm512_set_ps(-16.0f, 15.0f, -14.0f, 13.0f, -12.0f, 11.0f, -10.0f, 9.0f, -8.0f, 7.0f, -6.0f, 5.0f, -4.0f, 3.0f, -2.0f, 1.0f), 1.0f, -2.0f, 3.0f, -4.0f, 5.0f, -6.0f, 7.0f, -8.0f, 9.0f, -10.0f, 11.0f, -12.0f, 13.0f, -14.0f, 15.0f, -16.0f)); __m512i test_mm512_mask_abs_epi64 (__m512i __W, __mmask8 __U, __m512i __A) { >From 9f81cec74fadd739a43eff9301a6f671c009b290 Mon Sep 17 00:00:00 2001 From: Bhasawut Singhaphan <bhasa...@gmail.com> Date: Mon, 11 Aug 2025 15:36:09 +0700 Subject: [PATCH 5/7] Add tests for _mm512_set4_* --- clang/test/CodeGen/X86/avx512f-builtins.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/clang/test/CodeGen/X86/avx512f-builtins.c b/clang/test/CodeGen/X86/avx512f-builtins.c index 1ce4bf1985e6f..048bc3057b5f4 100644 --- a/clang/test/CodeGen/X86/avx512f-builtins.c +++ b/clang/test/CodeGen/X86/avx512f-builtins.c @@ -9136,6 +9136,7 @@ __m512i test_mm512_set4_epi32 (int __A, int __B, int __C, int __D) // CHECK: insertelement <16 x i32> {{.*}}, i32 15 return _mm512_set4_epi32 (__A,__B,__C,__D); } +TEST_CONSTEXPR(match_v16si(_mm512_set4_epi32(10, 20, 30, 40), 40, 30, 20, 10, 40, 30, 20, 10, 40, 30, 20, 10, 40, 30, 20, 10)); __m512i test_mm512_set4_epi64 (long long __A, long long __B, long long __C, long long __D) { @@ -9143,6 +9144,7 @@ __m512i test_mm512_set4_epi64 (long long __A, long long __B, long long __C, long // CHECK: insertelement <8 x i64> {{.*}}, i32 7 return _mm512_set4_epi64 (__A,__B,__C,__D); } +TEST_CONSTEXPR(match_v8di(_mm512_set4_epi64(1, -3, 5, -7), -7, 5, -3, 1, -7, 5, -3, 1)); __m512d test_mm512_set4_pd (double __A, double __B, double __C, double __D) { @@ -9150,6 +9152,7 @@ __m512d test_mm512_set4_pd (double __A, double __B, double __C, double __D) // CHECK: insertelement <8 x double> {{.*}}, i32 7 return _mm512_set4_pd (__A,__B,__C,__D); } +TEST_CONSTEXPR(match_m512d(_mm512_set4_pd(10.0, 20.0, 30.0, 40.0), 40.0, 30.0, 20.0, 10.0, 40.0, 30.0, 20.0, 10.0)); __m512 test_mm512_set4_ps (float __A, float __B, float __C, float __D) { @@ -9157,6 +9160,7 @@ __m512 test_mm512_set4_ps (float __A, float __B, float __C, float __D) // CHECK: insertelement <16 x float> {{.*}}, i32 15 return _mm512_set4_ps (__A,__B,__C,__D); } +TEST_CONSTEXPR(match_m512(_mm512_set4_ps(1.1f, 2.2f, 3.3f, 4.4f), 4.4f, 3.3f, 2.2f, 1.1f, 4.4f, 3.3f, 2.2f, 1.1f, 4.4f, 3.3f, 2.2f, 1.1f, 4.4f, 3.3f, 2.2f, 1.1f)); __m512i test_mm512_setr4_epi32(int e0, int e1, int e2, int e3) { >From 567ef7c493c0b41898bb6d9acf277a501fcf5ac7 Mon Sep 17 00:00:00 2001 From: Bhasawut Singhaphan <bhasa...@gmail.com> Date: Mon, 11 Aug 2025 20:47:36 +0700 Subject: [PATCH 6/7] Update builtin_test_helpers.h --- clang/test/CodeGen/X86/builtin_test_helpers.h | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/clang/test/CodeGen/X86/builtin_test_helpers.h b/clang/test/CodeGen/X86/builtin_test_helpers.h index 5d4ee7d05d356..21028443426ec 100644 --- a/clang/test/CodeGen/X86/builtin_test_helpers.h +++ b/clang/test/CodeGen/X86/builtin_test_helpers.h @@ -36,6 +36,11 @@ constexpr bool match_m128d(__m128d v, double a, double b) { return v[0] == a && v[1] == b; } +constexpr bool match_m128h(__m128h _v, _Float16 __e00, _Float16 __e01, _Float16 __e02, _Float16 __e03, _Float16 __e04, _Float16 __e05, _Float16 __e06, _Float16 __e07) { + __v8hf v = (__v8hf)_v; + return v[ 0] == __e00 && v[ 1] == __e01 && v[ 2] == __e02 && v[ 3] == __e03 && v[ 4] == __e04 && v[ 5] == __e05 && v[ 6] == __e06 && v[ 7] == __e07; +} + constexpr bool match_m128i(__m128i _v, unsigned long long a, unsigned long long b) { __v2du v = (__v2du)_v; return v[0] == a && v[1] == b; @@ -68,6 +73,13 @@ constexpr bool match_m256d(__m256d v, double a, double b, double c, double d) { return v[0] == a && v[1] == b && v[2] == c && v[3] == d; } +constexpr bool match_m256h(__m256h _v, _Float16 __e00, _Float16 __e01, _Float16 __e02, _Float16 __e03, _Float16 __e04, _Float16 __e05, _Float16 __e06, _Float16 __e07, + _Float16 __e08, _Float16 __e09, _Float16 __e10, _Float16 __e11, _Float16 __e12, _Float16 __e13, _Float16 __e14, _Float16 __e15) { + __v16hf v = (__v16hf)_v; + return v[ 0] == __e00 && v[ 1] == __e01 && v[ 2] == __e02 && v[ 3] == __e03 && v[ 4] == __e04 && v[ 5] == __e05 && v[ 6] == __e06 && v[ 7] == __e07 && + v[ 8] == __e08 && v[ 9] == __e09 && v[10] == __e10 && v[11] == __e11 && v[12] == __e12 && v[13] == __e13 && v[14] == __e14 && v[15] == __e15; +} + constexpr bool match_m256i(__m256i _v, unsigned long long a, unsigned long long b, unsigned long long c, unsigned long long d) { __v4du v = (__v4du)_v; return v[0] == a && v[1] == b && v[2] == c && v[3] == d; @@ -107,6 +119,17 @@ constexpr bool match_m512d(__m512d v, double a, double b, double c, double d, do return v[0] == a && v[1] == b && v[2] == c && v[3] == d && v[4] == e && v[5] == f && v[6] == g && v[7] == h; } +constexpr bool match_m512h(__m512h _v, _Float16 __e00, _Float16 __e01, _Float16 __e02, _Float16 __e03, _Float16 __e04, _Float16 __e05, _Float16 __e06, _Float16 __e07, + _Float16 __e08, _Float16 __e09, _Float16 __e10, _Float16 __e11, _Float16 __e12, _Float16 __e13, _Float16 __e14, _Float16 __e15, + _Float16 __e16, _Float16 __e17, _Float16 __e18, _Float16 __e19, _Float16 __e20, _Float16 __e21, _Float16 __e22, _Float16 __e23, + _Float16 __e24, _Float16 __e25, _Float16 __e26, _Float16 __e27, _Float16 __e28, _Float16 __e29, _Float16 __e30, _Float16 __e31) { + __v32hf v = (__v32hf)_v; + return v[ 0] == __e00 && v[ 1] == __e01 && v[ 2] == __e02 && v[ 3] == __e03 && v[ 4] == __e04 && v[ 5] == __e05 && v[ 6] == __e06 && v[ 7] == __e07 && + v[ 8] == __e08 && v[ 9] == __e09 && v[10] == __e10 && v[11] == __e11 && v[12] == __e12 && v[13] == __e13 && v[14] == __e14 && v[15] == __e15 && + v[16] == __e16 && v[17] == __e17 && v[18] == __e18 && v[19] == __e19 && v[20] == __e20 && v[21] == __e21 && v[22] == __e22 && v[23] == __e23 && + v[24] == __e24 && v[25] == __e25 && v[26] == __e26 && v[27] == __e27 && v[28] == __e28 && v[29] == __e29 && v[30] == __e30 && v[31] == __e31; +} + constexpr bool match_m512i(__m512i _v, unsigned long long a, unsigned long long b, unsigned long long c, unsigned long long d, unsigned long long e, unsigned long long f, unsigned long long g, unsigned long long h) { __v8du v = (__v8du)_v; return v[0] == a && v[1] == b && v[2] == c && v[3] == d && v[4] == e && v[5] == f && v[6] == g && v[7] == h; >From 245b4d14e64887c290d8550a002bbd8c3983bf28 Mon Sep 17 00:00:00 2001 From: Bhasawut Singhaphan <bhasa...@gmail.com> Date: Mon, 11 Aug 2025 20:49:57 +0700 Subject: [PATCH 7/7] Update avx512fp16-builtin tests to use corrected types --- clang/test/CodeGen/X86/avx512fp16-builtins.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/clang/test/CodeGen/X86/avx512fp16-builtins.c b/clang/test/CodeGen/X86/avx512fp16-builtins.c index e52610af16c63..70425ff878368 100644 --- a/clang/test/CodeGen/X86/avx512fp16-builtins.c +++ b/clang/test/CodeGen/X86/avx512fp16-builtins.c @@ -17,14 +17,14 @@ __m128h test_mm_setzero_ph(void) { // CHECK: zeroinitializer return _mm_setzero_ph(); } -TEST_CONSTEXPR(match_m128(_mm_setzero_ph(), +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f)); +TEST_CONSTEXPR(match_m128h(_mm_setzero_ph(), +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f)); __m256h test_mm256_setzero_ph(void) { // CHECK-LABEL: test_mm256_setzero_ph // CHECK: zeroinitializer return _mm256_setzero_ph(); } -TEST_CONSTEXPR(match_m256(_mm256_setzero_ph(), +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f)); +TEST_CONSTEXPR(match_m256h(_mm256_setzero_ph(), +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f)); __m256h test_mm256_undefined_ph(void) { // CHECK-LABEL: test_mm256_undefined_ph @@ -37,7 +37,7 @@ __m512h test_mm512_setzero_ph(void) { // CHECK: zeroinitializer return _mm512_setzero_ph(); } -TEST_CONSTEXPR(match_m512(_mm512_setzero_ph(), +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f)); +TEST_CONSTEXPR(match_m512h(_mm512_setzero_ph(), +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f)); __m128h test_mm_undefined_ph(void) { // CHECK-LABEL: test_mm_undefined_ph @@ -87,7 +87,7 @@ __m512h test_mm512_set1_ph(_Float16 h) { // CHECK: insertelement <32 x half> {{.*}}, i32 31 return _mm512_set1_ph(h); } -TEST_CONSTEXPR(match_m512(_mm512_set1_ph(-101.0f), -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f)); +TEST_CONSTEXPR(match_m512h(_mm512_set1_ph(-101.0f), -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f, -101.0f)); __m512h test_mm512_set1_pch(_Float16 _Complex h) { // CHECK-LABEL: test_mm512_set1_pch @@ -157,10 +157,10 @@ __m512h test_mm512_set_ph(_Float16 __h1, _Float16 __h2, _Float16 __h3, _Float16 __h17, __h18, __h19, __h20, __h21, __h22, __h23, __h24, __h25, __h26, __h27, __h28, __h29, __h30, __h31, __h32); } -TEST_CONSTEXPR(match_mm512(_mm512_set_ph(-1.0f, 2.0f, -3.0f, 4.0f, -5.0f, 6.0f, -7.0f, 8.0f, - -9.0f, 10.0f, -11.0f, 12.0f, -13.0f, 14.0f, -15.0f, 16.0f, - -17.0f, 18.0f, -19.0f, 20.0f, -21.0f, 22.0f, -23.0f, 24.0f, - -25.0f, 26.0f, -27.0f, 28.0f, -29.0f, 30.0f, -31.0f, 32.0f), -1.0f, 2.0f, -3.0f, 4.0f, -5.0f, 6.0f, -7.0f, 8.0f, +TEST_CONSTEXPR(match_mm512h(_mm512_set_ph(32.0f, -31.0f, 30.0f, -29.0f, 28.0f, -27.0f, 26.0f, -25.0f, + 24.0f, -23.0f, 22.0f, -21.0f, 20.0f, -19.0f, 18.0f, -17.0f, + 16.0f, -15.0f, 14.0f, -13.0f, 12.0f, -11.0f, 10.0f, -9.0f, + 8.0f, -7.0f, 6.0f, -5.0f, 4.0f, -3.0f, 2.0f, -1.0f), -1.0f, 2.0f, -3.0f, 4.0f, -5.0f, 6.0f, -7.0f, 8.0f, -9.0f, 10.0f, -11.0f, 12.0f, -13.0f, 14.0f, -15.0f, 16.0f, -17.0f, 18.0f, -19.0f, 20.0f, -21.0f, 22.0f, -23.0f, 24.0f, -25.0f, 26.0f, -27.0f, 28.0f, -29.0f, 30.0f, -31.0f, 32.0f)); @@ -211,7 +211,7 @@ __m512h test_mm512_setr_ph(_Float16 __h1, _Float16 __h2, _Float16 __h3, _Float16 __h17, __h18, __h19, __h20, __h21, __h22, __h23, __h24, __h25, __h26, __h27, __h28, __h29, __h30, __h31, __h32); } -TEST_CONSTEXPR(match_mm512(_mm512_setr_ph(1.0f, -3.0f, 5.0f, -7.0f, 9.0f, -11.0f, 13.0f, -15.0f, +TEST_CONSTEXPR(match_mm512h(_mm512_setr_ph(1.0f, -3.0f, 5.0f, -7.0f, 9.0f, -11.0f, 13.0f, -15.0f, 17.0f, -19.0f, 21.0f, -23.0f, 25.0f, -27.0f, 29.0f, -31.0f, 33.0f, -35.0f, 37.0f, -39.0f, 41.0f, -43.0f, 45.0f, -47.0f, 49.0f, -51.0f, 53.0f, -55.0f, 57.0f, -59.0f, 61.0f, -63.0f), _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits