206 lines · c
1// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bf16 -target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s2// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +avx512bf16 -target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s3// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bf16 -target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s4// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +avx512bf16 -target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s5//6// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bf16 -target-feature +avx512vl -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s7// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +avx512bf16 -target-feature +avx512vl -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s8// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bf16 -target-feature +avx512vl -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s9// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +avx512bf16 -target-feature +avx512vl -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s10 11#include <immintrin.h>12#include "builtin_test_helpers.h"13 14__m128bh test_mm_cvtne2ps2bf16(__m128 A, __m128 B) {15 // CHECK-LABEL: test_mm_cvtne2ps2bf1616 // CHECK: call {{.*}}<8 x bfloat> @llvm.x86.avx512bf16.cvtne2ps2bf16.128(<4 x float> %{{.*}}, <4 x float> %{{.*}})17 return _mm_cvtne2ps_pbh(A, B);18}19 20__m128bh test_mm_maskz_cvtne2ps2bf16(__m128 A, __m128 B, __mmask8 U) {21 // CHECK-LABEL: test_mm_maskz_cvtne2ps2bf1622 // CHECK: call {{.*}}<8 x bfloat> @llvm.x86.avx512bf16.cvtne2ps2bf16.128(<4 x float> %{{.*}}, <4 x float> %{{.*}})23 // CHECK: select <8 x i1> %{{.*}}, <8 x bfloat> %{{.*}}, <8 x bfloat> %{{.*}}24 return _mm_maskz_cvtne2ps_pbh(U, A, B);25}26 27__m128bh test_mm_mask_cvtne2ps2bf16(__m128bh C, __mmask8 U, __m128 A, __m128 B) {28 // CHECK-LABEL: test_mm_mask_cvtne2ps2bf1629 // CHECK: call {{.*}}<8 x bfloat> @llvm.x86.avx512bf16.cvtne2ps2bf16.128(<4 x float> %{{.*}}, <4 x float> %{{.*}})30 // CHECK: select <8 x i1> %{{.*}}, <8 x bfloat> %{{.*}}, <8 x bfloat> %{{.*}}31 return _mm_mask_cvtne2ps_pbh(C, U, A, B);32}33 34__m256bh test_mm256_cvtne2ps2bf16(__m256 A, __m256 B) {35 // CHECK-LABEL: test_mm256_cvtne2ps2bf1636 // CHECK: call {{.*}}<16 x bfloat> @llvm.x86.avx512bf16.cvtne2ps2bf16.256(<8 x float> %{{.*}}, <8 x float> %{{.*}})37 return _mm256_cvtne2ps_pbh(A, B);38}39 40__m256bh test_mm256_maskz_cvtne2ps2bf16(__m256 A, __m256 B, __mmask16 U) {41 // CHECK-LABEL: test_mm256_maskz_cvtne2ps2bf1642 // CHECK: call {{.*}}<16 x bfloat> @llvm.x86.avx512bf16.cvtne2ps2bf16.256(<8 x float> %{{.*}}, <8 x float> %{{.*}})43 // CHECK: select <16 x i1> %{{.*}}, <16 x bfloat> %{{.*}}, <16 x bfloat> %{{.*}}44 return _mm256_maskz_cvtne2ps_pbh(U, A, B);45}46 47__m256bh test_mm256_mask_cvtne2ps2bf16(__m256bh C, __mmask16 U, __m256 A, __m256 B) {48 // CHECK-LABEL: test_mm256_mask_cvtne2ps2bf1649 // CHECK: call {{.*}}<16 x bfloat> @llvm.x86.avx512bf16.cvtne2ps2bf16.256(<8 x float> %{{.*}}, <8 x float> %{{.*}})50 // CHECK: select <16 x i1> %{{.*}}, <16 x bfloat> %{{.*}}, <16 x bfloat> %{{.*}}51 return _mm256_mask_cvtne2ps_pbh(C, U, A, B);52}53 54__m512bh test_mm512_cvtne2ps2bf16(__m512 A, __m512 B) {55 // CHECK-LABEL: test_mm512_cvtne2ps2bf1656 // CHECK: call {{.*}}<32 x bfloat> @llvm.x86.avx512bf16.cvtne2ps2bf16.512(<16 x float> %{{.*}}, <16 x float> %{{.*}})57 return _mm512_cvtne2ps_pbh(A, B);58}59 60__m512bh test_mm512_maskz_cvtne2ps2bf16(__m512 A, __m512 B, __mmask32 U) {61 // CHECK-LABEL: test_mm512_maskz_cvtne2ps2bf1662 // CHECK: call {{.*}}<32 x bfloat> @llvm.x86.avx512bf16.cvtne2ps2bf16.512(<16 x float> %{{.*}}, <16 x float> %{{.*}})63 // CHECK: select <32 x i1> %{{.*}}, <32 x bfloat> %{{.*}}, <32 x bfloat> %{{.*}}64 return _mm512_maskz_cvtne2ps_pbh(U, A, B);65}66 67__m512bh test_mm512_mask_cvtne2ps2bf16(__m512bh C, __mmask32 U, __m512 A, __m512 B) {68 // CHECK-LABEL: test_mm512_mask_cvtne2ps2bf1669 // CHECK: call {{.*}}<32 x bfloat> @llvm.x86.avx512bf16.cvtne2ps2bf16.512(<16 x float> %{{.*}}, <16 x float> %{{.*}})70 // CHECK: select <32 x i1> %{{.*}}, <32 x bfloat> %{{.*}}, <32 x bfloat> %{{.*}}71 return _mm512_mask_cvtne2ps_pbh(C, U, A, B);72}73 74__m128bh test_mm_cvtneps2bf16(__m128 A) {75 // CHECK-LABEL: test_mm_cvtneps2bf1676 // CHECK: call {{.*}}<8 x bfloat> @llvm.x86.vcvtneps2bf16128(<4 x float> %{{.*}})77 return _mm_cvtneps_pbh(A);78}79 80__m128bh test_mm_mask_cvtneps2bf16(__m128bh C, __mmask8 U, __m128 A) {81 // CHECK-LABEL: test_mm_mask_cvtneps2bf1682 // CHECK: call {{.*}}<8 x bfloat> @llvm.x86.avx512bf16.mask.cvtneps2bf16.128(<4 x float> %{{.*}}, <8 x bfloat> %{{.*}}, <4 x i1> %{{.*}})83 return _mm_mask_cvtneps_pbh(C, U, A);84}85 86__m128bh test_mm_maskz_cvtneps2bf16(__m128 A, __mmask8 U) {87 // CHECK-LABEL: test_mm_maskz_cvtneps2bf1688 // CHECK: call {{.*}}<8 x bfloat> @llvm.x86.avx512bf16.mask.cvtneps2bf16.128(<4 x float> %{{.*}}, <8 x bfloat> %{{.*}}, <4 x i1> %{{.*}})89 return _mm_maskz_cvtneps_pbh(U, A);90}91 92__m128bh test_mm256_cvtneps2bf16(__m256 A) {93 // CHECK-LABEL: test_mm256_cvtneps2bf1694 // CHECK: call {{.*}}<8 x bfloat> @llvm.x86.vcvtneps2bf16256(<8 x float> %{{.*}})95 return _mm256_cvtneps_pbh(A);96}97 98__m128bh test_mm256_mask_cvtneps2bf16(__m128bh C, __mmask8 U, __m256 A) {99 // CHECK-LABEL: test_mm256_mask_cvtneps2bf16100 // CHECK: call {{.*}}<8 x bfloat> @llvm.x86.avx512bf16.cvtneps2bf16.256(<8 x float> %{{.*}})101 // CHECK: select <8 x i1> %{{.*}}, <8 x bfloat> %{{.*}}, <8 x bfloat> %{{.*}}102 return _mm256_mask_cvtneps_pbh(C, U, A);103}104 105__m128bh test_mm256_maskz_cvtneps2bf16(__m256 A, __mmask8 U) {106 // CHECK-LABEL: test_mm256_maskz_cvtneps2bf16107 // CHECK: call {{.*}}<8 x bfloat> @llvm.x86.avx512bf16.cvtneps2bf16.256108 // CHECK: select <8 x i1> %{{.*}}, <8 x bfloat> %{{.*}}, <8 x bfloat> %{{.*}}109 return _mm256_maskz_cvtneps_pbh(U, A);110}111 112__m128 test_mm_dpbf16_ps(__m128 D, __m128bh A, __m128bh B) {113 // CHECK-LABEL: test_mm_dpbf16_ps114 // CHECK: call {{.*}}<4 x float> @llvm.x86.avx512bf16.dpbf16ps.128(<4 x float> %{{.*}}, <8 x bfloat> %{{.*}}, <8 x bfloat> %{{.*}})115 return _mm_dpbf16_ps(D, A, B);116}117 118__m128 test_mm_maskz_dpbf16_ps(__m128 D, __m128bh A, __m128bh B, __mmask8 U) {119 // CHECK-LABEL: test_mm_maskz_dpbf16_ps120 // CHECK: call {{.*}}<4 x float> @llvm.x86.avx512bf16.dpbf16ps.128(<4 x float> %{{.*}}, <8 x bfloat> %{{.*}}, <8 x bfloat> %{{.*}})121 // CHECK: select <4 x i1> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}}122 return _mm_maskz_dpbf16_ps(U, D, A, B);123}124 125__m128 test_mm_mask_dpbf16_ps(__m128 D, __m128bh A, __m128bh B, __mmask8 U) {126 // CHECK-LABEL: test_mm_mask_dpbf16_ps127 // CHECK: call {{.*}}<4 x float> @llvm.x86.avx512bf16.dpbf16ps.128(<4 x float> %{{.*}}, <8 x bfloat> %{{.*}}, <8 x bfloat> %{{.*}})128 // CHECK: select <4 x i1> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}}129 return _mm_mask_dpbf16_ps(D, U, A, B);130}131 132__m256 test_mm256_dpbf16_ps(__m256 D, __m256bh A, __m256bh B) {133 // CHECK-LABEL: test_mm256_dpbf16_ps134 // CHECK: call {{.*}}<8 x float> @llvm.x86.avx512bf16.dpbf16ps.256(<8 x float> %{{.*}}, <16 x bfloat> %{{.*}}, <16 x bfloat> %{{.*}})135 return _mm256_dpbf16_ps(D, A, B);136}137 138__m256 test_mm256_maskz_dpbf16_ps(__m256 D, __m256bh A, __m256bh B, __mmask8 U) {139 // CHECK-LABEL: test_mm256_maskz_dpbf16_ps140 // CHECK: call {{.*}}<8 x float> @llvm.x86.avx512bf16.dpbf16ps.256(<8 x float> %{{.*}}, <16 x bfloat> %{{.*}}, <16 x bfloat> %{{.*}})141 // CHECK: select <8 x i1> %{{.*}}, <8 x float> %{{.*}}, <8 x float> %{{.*}}142 return _mm256_maskz_dpbf16_ps(U, D, A, B);143}144 145__m256 test_mm256_mask_dpbf16_ps(__m256 D, __m256bh A, __m256bh B, __mmask8 U) {146 // CHECK-LABEL: test_mm256_mask_dpbf16_ps147 // CHECK: call {{.*}}<8 x float> @llvm.x86.avx512bf16.dpbf16ps.256(<8 x float> %{{.*}}, <16 x bfloat> %{{.*}}, <16 x bfloat> %{{.*}})148 // CHECK: select <8 x i1> %{{.*}}, <8 x float> %{{.*}}, <8 x float> %{{.*}}149 return _mm256_mask_dpbf16_ps(D, U, A, B);150}151 152__bf16 test_mm_cvtness_sbh(float A) {153 // CHECK-LABEL: test_mm_cvtness_sbh154 // CHECK: call {{.*}}<8 x bfloat> @llvm.x86.avx512bf16.mask.cvtneps2bf16.128(<4 x float> %{{.*}}, <8 x bfloat> %{{.*}}, <4 x i1> splat (i1 true))155 return _mm_cvtness_sbh(A);156}157 158__m128 test_mm_cvtpbh_ps(__m128bh A) {159 // CHECK-LABEL: test_mm_cvtpbh_ps160 // CHECK: fpext <8 x bfloat> %{{.*}} to <8 x float>161 // CHECK: shufflevector <8 x float> %{{.*}}, <8 x float> %{{.*}}, <4 x i32> <i32 0, i32 1, i32 2, i32 3>162 return _mm_cvtpbh_ps(A);163}164TEST_CONSTEXPR(match_m128(_mm_cvtpbh_ps((__m128bh){-8.0f, 16.0f, -32.0f, 64.0f, -0.0f, 1.0f, -2.0f, 4.0f}), -8.0f, 16.0f, -32.0f, 64.0f));165 166__m256 test_mm256_cvtpbh_ps(__m128bh A) {167 // CHECK-LABEL: test_mm256_cvtpbh_ps168 // CHECK: fpext <8 x bfloat> %{{.*}} to <8 x float>169 return _mm256_cvtpbh_ps(A);170}171TEST_CONSTEXPR(match_m256(_mm256_cvtpbh_ps((__m128bh){-0.0f, 1.0f, -2.0f, 4.0f, -8.0f, 16.0f, -32.0f, 64.0f}), -0.0f, 1.0f, -2.0f, 4.0f, -8.0f, 16.0f, -32.0f, 64.0f));172 173__m128 test_mm_maskz_cvtpbh_ps(__mmask8 M, __m128bh A) {174 // CHECK-LABEL: test_mm_maskz_cvtpbh_ps175 // CHECK: fpext <8 x bfloat> %{{.*}} to <8 x float>176 // CHECK: shufflevector <8 x float> %{{.*}}, <8 x float> %{{.*}}, <4 x i32> <i32 0, i32 1, i32 2, i32 3>177 // CHECK: select <4 x i1> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}}178 return _mm_maskz_cvtpbh_ps(M, A);179}180TEST_CONSTEXPR(match_m128(_mm_maskz_cvtpbh_ps(0x01, (__m128bh){-0.0f, 1.0f, -2.0f, 4.0f, -8.0f, 16.0f, -32.0f, 64.0f}), -0.0f, 0.0f, 0.0f, 0.0f));181 182__m256 test_mm256_maskz_cvtpbh_ps(__mmask8 M, __m128bh A) {183 // CHECK-LABEL: test_mm256_maskz_cvtpbh_ps184 // CHECK: fpext <8 x bfloat> %{{.*}} to <8 x float>185 // CHECK: select <8 x i1> %{{.*}}, <8 x float> %{{.*}}, <8 x float> %{{.*}}186 return _mm256_maskz_cvtpbh_ps(M, A);187}188TEST_CONSTEXPR(match_m256(_mm256_maskz_cvtpbh_ps(0x73, (__m128bh){-0.0f, 1.0f, -2.0f, 4.0f, -8.0f, 16.0f, -32.0f, 64.0f}), -0.0f, 1.0f, 0.0f, 0.0f, -8.0f, 16.0f, -32.0f, 0.0f));189 190__m128 test_mm_mask_cvtpbh_ps(__m128 S, __mmask8 M, __m128bh A) {191 // CHECK-LABEL: test_mm_mask_cvtpbh_ps192 // CHECK: fpext <8 x bfloat> %{{.*}} to <8 x float>193 // CHECK: shufflevector <8 x float> %{{.*}}, <8 x float> %{{.*}}, <4 x i32> <i32 0, i32 1, i32 2, i32 3>194 // CHECK: select <4 x i1> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}}195 return _mm_mask_cvtpbh_ps(S, M, A);196}197TEST_CONSTEXPR(match_m128(_mm_mask_cvtpbh_ps((__m128){ 99.0f, 99.0f, 99.0f, 99.0f }, 0x03, (__m128bh){-0.0f, 1.0f, -2.0f, 4.0f, -8.0f, 16.0f, -32.0f, 64.0f}), -0.0f, 1.0f, 99.0f, 99.0f));198 199__m256 test_mm256_mask_cvtpbh_ps(__m256 S, __mmask8 M, __m128bh A) {200 // CHECK-LABEL: test_mm256_mask_cvtpbh_ps201 // CHECK: fpext <8 x bfloat> %{{.*}} to <8 x float>202 // CHECK: select <8 x i1> %{{.*}}, <8 x float> %{{.*}}, <8 x float> %{{.*}}203 return _mm256_mask_cvtpbh_ps(S, M, A);204}205TEST_CONSTEXPR(match_m256(_mm256_mask_cvtpbh_ps((__m256){ 99.0f, 99.0f, 99.0f, 99.0f, 99.0f, 99.0f, 99.0f, 99.0f }, 0x37, (__m128bh){-0.0f, 1.0f, -2.0f, 4.0f, -8.0f, 16.0f, -32.0f, 64.0f}), -0.0f, 1.0f, -2.0f, 99.0f, -8.0f, 16.0f, 99.0f, 99.0f));206