[clang] f257e9b - [clang][x86] Update AVX/AVX512 setzero constexpr tests to use the TEST_CONSTEXPR macro

Simon Pilgrim via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 29 07:34:35 PDT 2024


Author: Simon Pilgrim
Date: 2024-10-29T14:34:19Z
New Revision: f257e9bdbbb790e4fe0a5e2538c92d7edd85a2e5

URL: https://github.com/llvm/llvm-project/commit/f257e9bdbbb790e4fe0a5e2538c92d7edd85a2e5
DIFF: https://github.com/llvm/llvm-project/commit/f257e9bdbbb790e4fe0a5e2538c92d7edd85a2e5.diff

LOG: [clang][x86] Update AVX/AVX512 setzero constexpr tests to use the TEST_CONSTEXPR macro

Added: 
    

Modified: 
    clang/test/CodeGen/X86/avx-builtins.c
    clang/test/CodeGen/X86/avx512f-builtins.c
    clang/test/CodeGen/X86/builtin_test_helpers.h

Removed: 
    


################################################################################
diff  --git a/clang/test/CodeGen/X86/avx-builtins.c b/clang/test/CodeGen/X86/avx-builtins.c
index 9d6c1897f540d3..4e56204c8ad40f 100644
--- a/clang/test/CodeGen/X86/avx-builtins.c
+++ b/clang/test/CodeGen/X86/avx-builtins.c
@@ -11,6 +11,7 @@
 
 
 #include <immintrin.h>
+#include "builtin_test_helpers.h"
 
 // NOTE: This should match the tests in llvm/test/CodeGen/X86/avx-intrinsics-fast-isel.ll
 
@@ -1740,18 +1741,21 @@ __m256d test_mm256_setzero_pd(void) {
   // CHECK: store <4 x double> zeroinitializer
   return _mm256_setzero_pd();
 }
+TEST_CONSTEXPR(match_m256d(_mm256_setzero_pd(), +0.0, +0.0, +0.0, +0.0));
 
 __m256 test_mm256_setzero_ps(void) {
   // CHECK-LABEL: test_mm256_setzero_ps
   // CHECK: store <8 x float> zeroinitializer
   return _mm256_setzero_ps();
 }
+TEST_CONSTEXPR(match_m256(_mm256_setzero_ps(), +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f));
 
 __m256i test_mm256_setzero_si256(void) {
   // CHECK-LABEL: test_mm256_setzero_si256
   // CHECK: store <4 x i64> zeroinitializer
   return _mm256_setzero_si256();
 }
+TEST_CONSTEXPR(match_m256i(_mm256_setzero_si256(), 0, 0, 0, 0));
 
 __m256d test_mm256_shuffle_pd(__m256d A, __m256d B) {
   // CHECK-LABEL: test_mm256_shuffle_pd
@@ -2097,19 +2101,3 @@ float test_mm256_cvtss_f32(__m256 __a)
   // CHECK: extractelement <8 x float> %{{.*}}, i32 0
   return _mm256_cvtss_f32(__a);
 }
-
-// Test constexpr handling.
-#if defined(__cplusplus) && (__cplusplus >= 201103L)
-
-void test_constexpr() {
-  constexpr __m256d v_mm256_setzero_pd = _mm256_setzero_pd();
-  static_assert(v_mm256_setzero_pd[0] == +0.0 && v_mm256_setzero_pd[1] == +0.0 && v_mm256_setzero_pd[2] == +0.0 && v_mm256_setzero_pd[3] == +0.0);
-
-  constexpr __m256 v_mm256_setzero_ps = _mm256_setzero_ps();
-  static_assert(v_mm256_setzero_ps[0] == +0.0f && v_mm256_setzero_ps[1] == +0.0f && v_mm256_setzero_ps[2] == +0.0f && v_mm256_setzero_ps[3] == +0.0f && v_mm256_setzero_ps[4] == +0.0f && v_mm256_setzero_ps[5] == +0.0f && v_mm256_setzero_ps[6] == +0.0f && v_mm256_setzero_ps[7] == +0.0f);
-
-  constexpr __m256i v_mm256_setzero_si256 = _mm256_setzero_si256();
-  static_assert(v_mm256_setzero_si256[0] == 0x0000000000000000ULL && v_mm256_setzero_si256[1] == 0x0000000000000000ULL && v_mm256_setzero_si256[2] == 0x0000000000000000ULL && v_mm256_setzero_si256[3] == 0x0000000000000000ULL);
-}
-
-#endif

diff  --git a/clang/test/CodeGen/X86/avx512f-builtins.c b/clang/test/CodeGen/X86/avx512f-builtins.c
index 0b4f778a0637ab..372790a8cd668b 100644
--- a/clang/test/CodeGen/X86/avx512f-builtins.c
+++ b/clang/test/CodeGen/X86/avx512f-builtins.c
@@ -4,6 +4,7 @@
 // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -fms-extensions -fms-compatibility -ffreestanding %s -triple=x86_64-windows-msvc -target-feature +avx512f -emit-llvm -o - -Wall -Werror -Wsign-conversion | FileCheck %s
 
 #include <immintrin.h>
+#include "builtin_test_helpers.h"
 
 __m512d test_mm512_sqrt_pd(__m512d a)
 {
@@ -10615,13 +10616,13 @@ __m128 test_mm_maskz_cvtsd_ss(__mmask8 __U, __m128 __A, __m128d __B) {
   return _mm_maskz_cvtsd_ss(__U, __A, __B); 
 }
 
-
 __m512i test_mm512_setzero_epi32(void)
 {
   // CHECK-LABEL: test_mm512_setzero_epi32
   // CHECK: zeroinitializer
   return _mm512_setzero_epi32();
 }
+TEST_CONSTEXPR(match_m512i(_mm512_setzero_epi32(), 0, 0, 0, 0, 0, 0, 0, 0));
 
 __m512 test_mm512_setzero(void)
 {
@@ -10629,6 +10630,7 @@ __m512 test_mm512_setzero(void)
   // CHECK: zeroinitializer
   return _mm512_setzero();
 }
+TEST_CONSTEXPR(match_m512(_mm512_setzero(), +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));
 
 __m512i test_mm512_setzero_si512(void)
 {
@@ -10636,6 +10638,7 @@ __m512i test_mm512_setzero_si512(void)
   // CHECK: zeroinitializer
   return _mm512_setzero_si512();
 }
+TEST_CONSTEXPR(match_m512i(_mm512_setzero_si512(), 0, 0, 0, 0, 0, 0, 0, 0));
 
 __m512 test_mm512_setzero_ps(void)
 {
@@ -10643,6 +10646,7 @@ __m512 test_mm512_setzero_ps(void)
   // CHECK: zeroinitializer
   return _mm512_setzero_ps();
 }
+TEST_CONSTEXPR(match_m512(_mm512_setzero_ps(), +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));
 
 __m512d test_mm512_setzero_pd(void)
 {
@@ -10650,6 +10654,7 @@ __m512d test_mm512_setzero_pd(void)
   // CHECK: zeroinitializer
   return _mm512_setzero_pd();
 }
+TEST_CONSTEXPR(match_m512d(_mm512_setzero_pd(), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
 
 __mmask16 test_mm512_int2mask(int __a)
 {
@@ -10880,25 +10885,3 @@ void test_mm512_mask_i32loscatter_epi64(void *__addr, __mmask8 __mask, __m512i _
   // CHECK: @llvm.x86.avx512.mask.scatter.dpq.512
   _mm512_mask_i32loscatter_epi64(__addr, __mask, __index, __v1, 2);
 }
-
-// Test constexpr handling.
-#if defined(__cplusplus) && (__cplusplus >= 201103L)
-
-void test_constexpr() {
-  constexpr __m512 v_mm512_setzero = _mm512_setzero();
-  static_assert(v_mm512_setzero[0] == +0.0f && v_mm512_setzero[1] == +0.0f && v_mm512_setzero[2] == +0.0f && v_mm512_setzero[3] == +0.0f && v_mm512_setzero[4] == +0.0f && v_mm512_setzero[5] == +0.0f && v_mm512_setzero[6] == +0.0f && v_mm512_setzero[7] == +0.0f && v_mm512_setzero[8] == +0.0f && v_mm512_setzero[9] == +0.0f && v_mm512_setzero[10] == +0.0f && v_mm512_setzero[11] == +0.0f && v_mm512_setzero[12] == +0.0f && v_mm512_setzero[13] == +0.0f && v_mm512_setzero[14] == +0.0f && v_mm512_setzero[15] == +0.0f);
-
-  constexpr __m512 v_mm512_setzero_ps = _mm512_setzero_ps();
-  static_assert(v_mm512_setzero_ps[0] == +0.0f && v_mm512_setzero_ps[1] == +0.0f && v_mm512_setzero_ps[2] == +0.0f && v_mm512_setzero_ps[3] == +0.0f && v_mm512_setzero_ps[4] == +0.0f && v_mm512_setzero_ps[5] == +0.0f && v_mm512_setzero_ps[6] == +0.0f && v_mm512_setzero_ps[7] == +0.0f && v_mm512_setzero_ps[8] == +0.0f && v_mm512_setzero_ps[9] == +0.0f && v_mm512_setzero_ps[10] == +0.0f && v_mm512_setzero_ps[11] == +0.0f && v_mm512_setzero_ps[12] == +0.0f && v_mm512_setzero_ps[13] == +0.0f && v_mm512_setzero_ps[14] == +0.0f && v_mm512_setzero_ps[15] == +0.0f);
-
-  constexpr __m512d v_mm512_setzero_pd = _mm512_setzero_pd();
-  static_assert(v_mm512_setzero_pd[0] == +0.0 && v_mm512_setzero_pd[1] == +0.0 && v_mm512_setzero_pd[2] == +0.0 && v_mm512_setzero_pd[3] == +0.0 && v_mm512_setzero_pd[4] == +0.0 && v_mm512_setzero_pd[5] == +0.0 && v_mm512_setzero_pd[6] == +0.0 && v_mm512_setzero_pd[7] == +0.0);
-
-  constexpr __m512i v_mm512_setzero_si512 = _mm512_setzero_si512();
-  static_assert(v_mm512_setzero_si512[0] == 0x0000000000000000ULL && v_mm512_setzero_si512[1] == 0x0000000000000000ULL && v_mm512_setzero_si512[2] == 0x0000000000000000ULL && v_mm512_setzero_si512[3] == 0x0000000000000000ULL && v_mm512_setzero_si512[4] == 0x0000000000000000ULL && v_mm512_setzero_si512[5] == 0x0000000000000000ULL && v_mm512_setzero_si512[6] == 0x0000000000000000ULL && v_mm512_setzero_si512[7] == 0x0000000000000000ULL);
-
-  constexpr __m512i v_mm512_setzero_epi32 = _mm512_setzero_epi32();
-  static_assert(v_mm512_setzero_epi32[0] == 0x0000000000000000ULL && v_mm512_setzero_epi32[1] == 0x0000000000000000ULL && v_mm512_setzero_epi32[2] == 0x0000000000000000ULL && v_mm512_setzero_epi32[3] == 0x0000000000000000ULL && v_mm512_setzero_epi32[4] == 0x0000000000000000ULL && v_mm512_setzero_epi32[5] == 0x0000000000000000ULL && v_mm512_setzero_epi32[6] == 0x0000000000000000ULL && v_mm512_setzero_epi32[7] == 0x0000000000000000ULL);
-}
-
-#endif

diff  --git a/clang/test/CodeGen/X86/builtin_test_helpers.h b/clang/test/CodeGen/X86/builtin_test_helpers.h
index 043b6ecbc69f18..5e77ff3a7ca45e 100644
--- a/clang/test/CodeGen/X86/builtin_test_helpers.h
+++ b/clang/test/CodeGen/X86/builtin_test_helpers.h
@@ -4,16 +4,40 @@
 
 #if defined(__cplusplus) && (__cplusplus >= 201103L)
 
-constexpr bool match_m128(__m128 v, float x, float y, float z, float w) {
-  return v[0] == x && v[1] == y && v[2] == z && v[3] == w;
+constexpr bool match_m128(__m128 v, float a, float b, float c, float d) {
+  return v[0] == a && v[1] == b && v[2] == c && v[3] == d;
 }
 
-constexpr bool match_m128d(__m128d v, double x, double y) {
-  return v[0] == x && v[1] == y;
+constexpr bool match_m128d(__m128d v, double a, double b) {
+  return v[0] == a && v[1] == b;
 }
 
-constexpr bool match_m128i(__m128i v, unsigned long long x, unsigned long long y) {
-  return v[0] == x && v[1] == y;
+constexpr bool match_m128i(__m128i v, unsigned long long a, unsigned long long b) {
+  return v[0] == a && v[1] == b;
+}
+
+constexpr bool match_m256(__m256 v, float a, float b, float c, float d, float e, float f, float g, float h) {
+  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_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_m256i(__m256i v, unsigned long long a, unsigned long long b, unsigned long long c, unsigned long long d) {
+  return v[0] == a && v[1] == b && v[2] == c && v[3] == d;
+}
+
+constexpr bool match_m512(__m512 v, 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 v[0] == a && v[1] == b && v[2] == c && v[3] == d && v[4] == e && v[5] == f && v[6] == g && v[7] == h && v[8] == i && v[9] == j && v[10] == k && v[11] == l && v[12] == m && v[13] == n && v[14] == o && v[15] == p;
+}
+
+constexpr bool match_m512d(__m512d v, double a, double b, double c, double d, double e, double f, double g, double h) {
+  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_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) {
+  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;
 }
 
 #define TEST_CONSTEXPR(...) static_assert(__VA_ARGS__)
@@ -22,4 +46,4 @@ constexpr bool match_m128i(__m128i v, unsigned long long x, unsigned long long y
 
 #define TEST_CONSTEXPR(...)
 
-#endif
\ No newline at end of file
+#endif


        


More information about the cfe-commits mailing list