Clang Project

clang_source_code/test/CodeGen/f16c-builtins.c
1// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +f16c -emit-llvm -o - -Wall -Werror | FileCheck %s
2
3
4#include <immintrin.h>
5
6float test_cvtsh_ss(unsigned short a) {
7  // CHECK-LABEL: test_cvtsh_ss
8  // CHECK: insertelement <8 x i16> undef, i16 %{{.*}}, i32 0
9  // CHECK: insertelement <8 x i16> %{{.*}}, i16 0, i32 1
10  // CHECK: insertelement <8 x i16> %{{.*}}, i16 0, i32 2
11  // CHECK: insertelement <8 x i16> %{{.*}}, i16 0, i32 3
12  // CHECK: insertelement <8 x i16> %{{.*}}, i16 0, i32 4
13  // CHECK: insertelement <8 x i16> %{{.*}}, i16 0, i32 5
14  // CHECK: insertelement <8 x i16> %{{.*}}, i16 0, i32 6
15  // CHECK: insertelement <8 x i16> %{{.*}}, i16 0, i32 7
16  // CHECK: call <4 x float> @llvm.x86.vcvtph2ps.128(<8 x i16> %{{.*}})
17  // CHECK: extractelement <4 x float> %{{.*}}, i32 0
18  return _cvtsh_ss(a);
19}
20
21unsigned short test_cvtss_sh(float a) {
22  // CHECK-LABEL: test_cvtss_sh
23  // CHECK: insertelement <4 x float> undef, float %{{.*}}, i32 0
24  // CHECK: insertelement <4 x float> %{{.*}}, float 0.000000e+00, i32 1
25  // CHECK: insertelement <4 x float> %{{.*}}, float 0.000000e+00, i32 2
26  // CHECK: insertelement <4 x float> %{{.*}}, float 0.000000e+00, i32 3
27  // CHECK: call <8 x i16> @llvm.x86.vcvtps2ph.128(<4 x float> %{{.*}}, i32 0)
28  // CHECK: extractelement <8 x i16> %{{.*}}, i32 0
29  return _cvtss_sh(a, 0);
30}
31
32__m128 test_mm_cvtph_ps(__m128i a) {
33  // CHECK-LABEL: test_mm_cvtph_ps
34  // CHECK: call <4 x float> @llvm.x86.vcvtph2ps.128(<8 x i16> %{{.*}})
35  return _mm_cvtph_ps(a);
36}
37
38__m256 test_mm256_cvtph_ps(__m128i a) {
39  // CHECK-LABEL: test_mm256_cvtph_ps
40  // CHECK: call <8 x float> @llvm.x86.vcvtph2ps.256(<8 x i16> %{{.*}})
41  return _mm256_cvtph_ps(a);
42}
43
44__m128i test_mm_cvtps_ph(__m128 a) {
45  // CHECK-LABEL: test_mm_cvtps_ph
46  // CHECK: call <8 x i16> @llvm.x86.vcvtps2ph.128(<4 x float> %{{.*}}, i32 0)
47  return _mm_cvtps_ph(a, 0);
48}
49
50__m128i test_mm256_cvtps_ph(__m256 a) {
51  // CHECK-LABEL: test_mm256_cvtps_ph
52  // CHECK: call <8 x i16> @llvm.x86.vcvtps2ph.256(<8 x float> %{{.*}}, i32 0)
53  return _mm256_cvtps_ph(a, 0);
54}
55