]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/CodeGen/f16c-builtins.c
Vendor import of clang trunk r290819:
[FreeBSD/FreeBSD.git] / 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 <x86intrin.h>
5
6 float 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
21 unsigned 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 }