| 1 |
// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bf16 -emit-llvm -o - -Wall -Werror | FileCheck %s |
| 2 |
// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +avx512bf16 -emit-llvm -o - -Wall -Werror | FileCheck %s |
| 3 |
// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bf16 -emit-llvm -o - -Wall -Werror | FileCheck %s |
| 4 |
// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +avx512bf16 -emit-llvm -o - -Wall -Werror | FileCheck %s |
| 5 |
// |
| 6 |
// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bf16 -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s |
| 7 |
// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +avx512bf16 -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s |
| 8 |
// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bf16 -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s |
| 9 |
// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +avx512bf16 -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s |
| 10 |
|
| 11 |
#include <immintrin.h> |
| 12 |
#include "builtin_test_helpers.h" |
| 13 |
|
| 14 |
float test_mm_cvtsbh_ss(__bf16 A) { |
| 15 |
// CHECK-LABEL: test_mm_cvtsbh_ss |
| 16 |
// CHECK: fpext bfloat %{{.*}} to float |
| 17 |
// CHECK: ret float %{{.*}} |
| 18 |
return _mm_cvtsbh_ss(A); |
| 19 |
} |
| 20 |
TEST_CONSTEXPR(_mm_cvtsbh_ss(-1.0f) == -1.0f); |
| 21 |
|
| 22 |
__m512bh test_mm512_cvtne2ps_pbh(__m512 A, __m512 B) { |
| 23 |
// CHECK-LABEL: test_mm512_cvtne2ps_pbh |
| 24 |
// CHECK: call {{.*}}<32 x bfloat> @llvm.x86.avx512bf16.cvtne2ps2bf16.512(<16 x float> %{{.*}}, <16 x float> %{{.*}}) |
| 25 |
return _mm512_cvtne2ps_pbh(A, B); |
| 26 |
} |
| 27 |
|
| 28 |
__m512bh test_mm512_maskz_cvtne2ps_pbh(__m512 A, __m512 B, __mmask32 U) { |
| 29 |
// CHECK-LABEL: test_mm512_maskz_cvtne2ps_pbh |
| 30 |
// CHECK: call {{.*}}<32 x bfloat> @llvm.x86.avx512bf16.cvtne2ps2bf16.512(<16 x float> %{{.*}}, <16 x float> %{{.*}}) |
| 31 |
// CHECK: select <32 x i1> %{{.*}}, <32 x bfloat> %{{.*}}, <32 x bfloat> %{{.*}} |
| 32 |
return _mm512_maskz_cvtne2ps_pbh(U, A, B); |
| 33 |
} |
| 34 |
|
| 35 |
__m512bh test_mm512_mask_cvtne2ps_pbh(__m512bh C, __mmask32 U, __m512 A, __m512 B) { |
| 36 |
// CHECK-LABEL: test_mm512_mask_cvtne2ps_pbh |
| 37 |
// CHECK: call {{.*}}<32 x bfloat> @llvm.x86.avx512bf16.cvtne2ps2bf16.512(<16 x float> %{{.*}}, <16 x float> %{{.*}}) |
| 38 |
// CHECK: select <32 x i1> %{{.*}}, <32 x bfloat> %{{.*}}, <32 x bfloat> %{{.*}} |
| 39 |
return _mm512_mask_cvtne2ps_pbh(C, U, A, B); |
| 40 |
} |
| 41 |
|
| 42 |
__m256bh test_mm512_cvtneps_pbh(__m512 A) { |
| 43 |
// CHECK-LABEL: test_mm512_cvtneps_pbh |
| 44 |
// CHECK: call {{.*}}<16 x bfloat> @llvm.x86.avx512bf16.cvtneps2bf16.512(<16 x float> %{{.*}}) |
| 45 |
return _mm512_cvtneps_pbh(A); |
| 46 |
} |
| 47 |
|
| 48 |
__m256bh test_mm512_mask_cvtneps_pbh(__m256bh C, __mmask16 U, __m512 A) { |
| 49 |
// CHECK-LABEL: test_mm512_mask_cvtneps_pbh |
| 50 |
// CHECK: call {{.*}}<16 x bfloat> @llvm.x86.avx512bf16.cvtneps2bf16.512(<16 x float> %{{.*}}) |
| 51 |
// CHECK: select <16 x i1> %{{.*}}, <16 x bfloat> %{{.*}}, <16 x bfloat> %{{.*}} |
| 52 |
return _mm512_mask_cvtneps_pbh(C, U, A); |
| 53 |
} |
| 54 |
|
| 55 |
__m256bh test_mm512_maskz_cvtneps_pbh(__m512 A, __mmask16 U) { |
| 56 |
// CHECK-LABEL: test_mm512_maskz_cvtneps_pbh |
| 57 |
// CHECK: call {{.*}}<16 x bfloat> @llvm.x86.avx512bf16.cvtneps2bf16.512(<16 x float> %{{.*}}) |
| 58 |
// CHECK: select <16 x i1> %{{.*}}, <16 x bfloat> %{{.*}}, <16 x bfloat> %{{.*}} |
| 59 |
return _mm512_maskz_cvtneps_pbh(U, A); |
| 60 |
} |
| 61 |
|
| 62 |
__m512 test_mm512_dpbf16_ps(__m512 D, __m512bh A, __m512bh B) { |
| 63 |
// CHECK-LABEL: test_mm512_dpbf16_ps |
| 64 |
// CHECK: call {{.*}}<16 x float> @llvm.x86.avx512bf16.dpbf16ps.512(<16 x float> %{{.*}}, <32 x bfloat> %{{.*}}, <32 x bfloat> %{{.*}}) |
| 65 |
return _mm512_dpbf16_ps(D, A, B); |
| 66 |
} |
| 67 |
|
| 68 |
__m512 test_mm512_maskz_dpbf16_ps(__m512 D, __m512bh A, __m512bh B, __mmask16 U) { |
| 69 |
// CHECK-LABEL: test_mm512_maskz_dpbf16_ps |
| 70 |
// CHECK: call {{.*}}<16 x float> @llvm.x86.avx512bf16.dpbf16ps.512(<16 x float> %{{.*}}, <32 x bfloat> %{{.*}}, <32 x bfloat> %{{.*}}) |
| 71 |
// CHECK: select <16 x i1> %{{.*}}, <16 x float> %{{.*}}, <16 x float> %{{.*}} |
| 72 |
return _mm512_maskz_dpbf16_ps(U, D, A, B); |
| 73 |
} |
| 74 |
|
| 75 |
__m512 test_mm512_mask_dpbf16_ps(__m512 D, __m512bh A, __m512bh B, __mmask16 U) { |
| 76 |
// CHECK-LABEL: test_mm512_mask_dpbf16_ps |
| 77 |
// CHECK: call {{.*}}<16 x float> @llvm.x86.avx512bf16.dpbf16ps.512(<16 x float> %{{.*}}, <32 x bfloat> %{{.*}}, <32 x bfloat> %{{.*}}) |
| 78 |
// CHECK: select <16 x i1> %{{.*}}, <16 x float> %{{.*}}, <16 x float> %{{.*}} |
| 79 |
return _mm512_mask_dpbf16_ps(D, U, A, B); |
| 80 |
} |
| 81 |
|
| 82 |
__m512 test_mm512_cvtpbh_ps(__m256bh A) { |
| 83 |
// CHECK-LABEL: test_mm512_cvtpbh_ps |
| 84 |
// CHECK: fpext <16 x bfloat> %{{.*}} to <16 x float> |
| 85 |
return _mm512_cvtpbh_ps(A); |
| 86 |
} |
| 87 |
TEST_CONSTEXPR(match_m512(_mm512_cvtpbh_ps((__m256bh){-0.0f, 1.0f, -2.0f, 4.0f, -8.0f, 16.0f, -32.0f, 64.0f, -128.0f, -0.5f, 0.25f, -0.125f, -4.0f, 2.0f, -1.0f, 0.0f}), -0.0f, 1.0f, -2.0f, 4.0f, -8.0f, 16.0f, -32.0f, 64.0f, -128.0f, -0.5f, 0.25f, -0.125f, -4.0f, 2.0f, -1.0f, 0.0f)); |
| 88 |
|
| 89 |
__m512 test_mm512_maskz_cvtpbh_ps(__mmask16 M, __m256bh A) { |
| 90 |
// CHECK-LABEL: test_mm512_maskz_cvtpbh_ps |
| 91 |
// CHECK: fpext <16 x bfloat> %{{.*}} to <16 x float> |
| 92 |
// CHECK: select <16 x i1> %{{.*}}, <16 x float> %{{.*}}, <16 x float> %{{.*}} |
| 93 |
return _mm512_maskz_cvtpbh_ps(M, A); |
| 94 |
} |
| 95 |
TEST_CONSTEXPR(match_m512(_mm512_maskz_cvtpbh_ps(0xA753, (__m256bh){-0.0f, 1.0f, -2.0f, 4.0f, -8.0f, 16.0f, -32.0f, 64.0f, -128.0f, -0.5f, 0.25f, -0.125f, -4.0f, 2.0f, -1.0f, 0.0f}), -0.0f, 1.0f, 0.0f, 0.0f, -8.0f, 0.0f, -32.0f, 0.0f, -128.0f, -0.5f, 0.25f, 0.0f, 0.0f, 2.0f, 0.0f, 0.0f)); |
| 96 |
|
| 97 |
__m512 test_mm512_mask_cvtpbh_ps(__m512 S, __mmask16 M, __m256bh A) { |
| 98 |
// CHECK-LABEL: test_mm512_mask_cvtpbh_ps |
| 99 |
// CHECK: fpext <16 x bfloat> %{{.*}} to <16 x float> |
| 100 |
// CHECK: select <16 x i1> %{{.*}}, <16 x float> %{{.*}}, <16 x float> %{{.*}} |
| 101 |
return _mm512_mask_cvtpbh_ps(S, M, A); |
| 102 |
} |
| 103 |
TEST_CONSTEXPR(match_m512(_mm512_mask_cvtpbh_ps((__m512){ 99.0f, 99.0f, 99.0f, 99.0f, 99.0f, 99.0f, 99.0f, 99.0f, 99.0f, 99.0f, 99.0f, 99.0f, 99.0f, 99.0f, 99.0f, 99.0f }, 0xA753, (__m256bh){-0.0f, 1.0f, -2.0f, 4.0f, -8.0f, 16.0f, -32.0f, 64.0f, -128.0f, -0.5f, 0.25f, -0.125f, -4.0f, 2.0f, -1.0f, 0.0f}), -0.0f, 1.0f, 99.0f, 99.0f, -8.0f, 99.0f, -32.0f, 99.0f, -128.0f, -0.5f, 0.25f, 99.0f, 99.0f, 2.0f, 99.0f, 0.0f)); |