Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit c8706b2

Browse files
committed
[X86][F16C] Added F16C fast-isel tests to match clang/test/CodeGen/f16c-builtins.c
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270837 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 30719eb commit c8706b2

File tree

1 file changed

+130
-0
lines changed

1 file changed

+130
-0
lines changed
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: llc < %s -fast-isel -mtriple=i386-unknown-unknown -mattr=+avx,+f16c | FileCheck %s --check-prefix=ALL --check-prefix=X32
3+
; RUN: llc < %s -fast-isel -mtriple=x86_64-unknown-unknown -mattr=+avx,+f16c | FileCheck %s --check-prefix=ALL --check-prefix=X64
4+
5+
; NOTE: This should use IR equivalent to what is generated by clang/test/CodeGen/sse3-builtins.c
6+
7+
define float @test_cvtsh_ss(i16 %a0) nounwind {
8+
; X32-LABEL: test_cvtsh_ss:
9+
; X32: # BB#0:
10+
; X32-NEXT: pushl %eax
11+
; X32-NEXT: movzwl {{[0-9]+}}(%esp), %eax
12+
; X32-NEXT: vmovd %eax, %xmm0
13+
; X32-NEXT: vcvtph2ps %xmm0, %xmm0
14+
; X32-NEXT: vmovss %xmm0, (%esp)
15+
; X32-NEXT: flds (%esp)
16+
; X32-NEXT: popl %eax
17+
; X32-NEXT: retl
18+
;
19+
; X64-LABEL: test_cvtsh_ss:
20+
; X64: # BB#0:
21+
; X64-NEXT: movzwl %di, %eax
22+
; X64-NEXT: vmovd %eax, %xmm0
23+
; X64-NEXT: vcvtph2ps %xmm0, %xmm0
24+
; X64-NEXT: retq
25+
%ins0 = insertelement <8 x i16> undef, i16 %a0, i32 0
26+
%ins1 = insertelement <8 x i16> %ins0, i16 0, i32 1
27+
%ins2 = insertelement <8 x i16> %ins1, i16 0, i32 2
28+
%ins3 = insertelement <8 x i16> %ins2, i16 0, i32 3
29+
%ins4 = insertelement <8 x i16> %ins3, i16 0, i32 4
30+
%ins5 = insertelement <8 x i16> %ins4, i16 0, i32 5
31+
%ins6 = insertelement <8 x i16> %ins5, i16 0, i32 6
32+
%ins7 = insertelement <8 x i16> %ins6, i16 0, i32 7
33+
%cvt = call <4 x float> @llvm.x86.vcvtph2ps.128(<8 x i16> %ins7)
34+
%res = extractelement <4 x float> %cvt, i32 0
35+
ret float %res
36+
}
37+
38+
define i16 @test_cvtss_sh(float %a0) nounwind {
39+
; X32-LABEL: test_cvtss_sh:
40+
; X32: # BB#0:
41+
; X32-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
42+
; X32-NEXT: vxorps %xmm1, %xmm1, %xmm1
43+
; X32-NEXT: vmovss {{.*#+}} xmm0 = xmm0[0],xmm1[1,2,3]
44+
; X32-NEXT: vcvtps2ph $0, %xmm0, %xmm0
45+
; X32-NEXT: vmovd %xmm0, %eax
46+
; X32-NEXT: retl
47+
;
48+
; X64-LABEL: test_cvtss_sh:
49+
; X64: # BB#0:
50+
; X64-NEXT: vxorps %xmm1, %xmm1, %xmm1
51+
; X64-NEXT: vmovss {{.*#+}} xmm0 = xmm0[0],xmm1[1,2,3]
52+
; X64-NEXT: vcvtps2ph $0, %xmm0, %xmm0
53+
; X64-NEXT: vmovd %xmm0, %eax
54+
; X64-NEXT: retq
55+
%ins0 = insertelement <4 x float> undef, float %a0, i32 0
56+
%ins1 = insertelement <4 x float> %ins0, float 0.000000e+00, i32 1
57+
%ins2 = insertelement <4 x float> %ins1, float 0.000000e+00, i32 2
58+
%ins3 = insertelement <4 x float> %ins2, float 0.000000e+00, i32 3
59+
%cvt = call <8 x i16> @llvm.x86.vcvtps2ph.128(<4 x float> %ins3, i32 0)
60+
%res = extractelement <8 x i16> %cvt, i32 0
61+
ret i16 %res
62+
}
63+
64+
define <4 x float> @test_mm_cvtph_ps(<2 x i64> %a0) nounwind {
65+
; X32-LABEL: test_mm_cvtph_ps:
66+
; X32: # BB#0:
67+
; X32-NEXT: vcvtph2ps %xmm0, %xmm0
68+
; X32-NEXT: retl
69+
;
70+
; X64-LABEL: test_mm_cvtph_ps:
71+
; X64: # BB#0:
72+
; X64-NEXT: vcvtph2ps %xmm0, %xmm0
73+
; X64-NEXT: retq
74+
%arg0 = bitcast <2 x i64> %a0 to <8 x i16>
75+
%res = call <4 x float> @llvm.x86.vcvtph2ps.128(<8 x i16> %arg0)
76+
ret <4 x float> %res
77+
}
78+
79+
define <8 x float> @test_mm256_cvtph_ps(<2 x i64> %a0) nounwind {
80+
; X32-LABEL: test_mm256_cvtph_ps:
81+
; X32: # BB#0:
82+
; X32-NEXT: vcvtph2ps %xmm0, %ymm0
83+
; X32-NEXT: retl
84+
;
85+
; X64-LABEL: test_mm256_cvtph_ps:
86+
; X64: # BB#0:
87+
; X64-NEXT: vcvtph2ps %xmm0, %ymm0
88+
; X64-NEXT: retq
89+
%arg0 = bitcast <2 x i64> %a0 to <8 x i16>
90+
%res = call <8 x float> @llvm.x86.vcvtph2ps.256(<8 x i16> %arg0)
91+
ret <8 x float> %res
92+
}
93+
94+
define <2 x i64> @test_mm_cvtps_ph(<4 x float> %a0) nounwind {
95+
; X32-LABEL: test_mm_cvtps_ph:
96+
; X32: # BB#0:
97+
; X32-NEXT: vcvtps2ph $0, %xmm0, %xmm0
98+
; X32-NEXT: retl
99+
;
100+
; X64-LABEL: test_mm_cvtps_ph:
101+
; X64: # BB#0:
102+
; X64-NEXT: vcvtps2ph $0, %xmm0, %xmm0
103+
; X64-NEXT: retq
104+
%cvt = call <8 x i16> @llvm.x86.vcvtps2ph.128(<4 x float> %a0, i32 0)
105+
%res = bitcast <8 x i16> %cvt to <2 x i64>
106+
ret <2 x i64> %res
107+
}
108+
109+
define <2 x i64> @test_mm256_cvtps_ph(<8 x float> %a0) nounwind {
110+
; X32-LABEL: test_mm256_cvtps_ph:
111+
; X32: # BB#0:
112+
; X32-NEXT: vcvtps2ph $0, %ymm0, %xmm0
113+
; X32-NEXT: vzeroupper
114+
; X32-NEXT: retl
115+
;
116+
; X64-LABEL: test_mm256_cvtps_ph:
117+
; X64: # BB#0:
118+
; X64-NEXT: vcvtps2ph $0, %ymm0, %xmm0
119+
; X64-NEXT: vzeroupper
120+
; X64-NEXT: retq
121+
%cvt = call <8 x i16> @llvm.x86.vcvtps2ph.256(<8 x float> %a0, i32 0)
122+
%res = bitcast <8 x i16> %cvt to <2 x i64>
123+
ret <2 x i64> %res
124+
}
125+
126+
declare <4 x float> @llvm.x86.vcvtph2ps.128(<8 x i16>) nounwind readonly
127+
declare <8 x float> @llvm.x86.vcvtph2ps.256(<8 x i16>) nounwind readonly
128+
129+
declare <8 x i16> @llvm.x86.vcvtps2ph.128(<4 x float>, i32) nounwind readonly
130+
declare <8 x i16> @llvm.x86.vcvtps2ph.256(<8 x float>, i32) nounwind readonly

0 commit comments

Comments
 (0)