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=X32
3 ; RUN: llc < %s -fast-isel -mtriple=x86_64-unknown-unknown -mattr=+avx,+f16c | FileCheck %s --check-prefix=X64
5 ; NOTE: This should use IR equivalent to what is generated by clang/test/CodeGen/f16c-builtins.c
7 define float @test_cvtsh_ss(i16 %a0) nounwind {
8 ; X32-LABEL: test_cvtsh_ss:
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)
19 ; X64-LABEL: test_cvtsh_ss:
21 ; X64-NEXT: movzwl %di, %eax
22 ; X64-NEXT: vmovd %eax, %xmm0
23 ; X64-NEXT: vcvtph2ps %xmm0, %xmm0
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
38 define i16 @test_cvtss_sh(float %a0) nounwind {
39 ; X32-LABEL: test_cvtss_sh:
41 ; X32-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
42 ; X32-NEXT: vxorps %xmm1, %xmm1, %xmm1
43 ; X32-NEXT: vblendps {{.*#+}} xmm0 = xmm0[0],xmm1[1,2,3]
44 ; X32-NEXT: vcvtps2ph $0, %xmm0, %xmm0
45 ; X32-NEXT: vmovd %xmm0, %eax
46 ; X32-NEXT: # kill: def $ax killed $ax killed $eax
49 ; X64-LABEL: test_cvtss_sh:
51 ; X64-NEXT: vxorps %xmm1, %xmm1, %xmm1
52 ; X64-NEXT: vblendps {{.*#+}} xmm0 = xmm0[0],xmm1[1,2,3]
53 ; X64-NEXT: vcvtps2ph $0, %xmm0, %xmm0
54 ; X64-NEXT: vmovd %xmm0, %eax
55 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
57 %ins0 = insertelement <4 x float> undef, float %a0, i32 0
58 %ins1 = insertelement <4 x float> %ins0, float 0.000000e+00, i32 1
59 %ins2 = insertelement <4 x float> %ins1, float 0.000000e+00, i32 2
60 %ins3 = insertelement <4 x float> %ins2, float 0.000000e+00, i32 3
61 %cvt = call <8 x i16> @llvm.x86.vcvtps2ph.128(<4 x float> %ins3, i32 0)
62 %res = extractelement <8 x i16> %cvt, i32 0
66 define <4 x float> @test_mm_cvtph_ps(<2 x i64> %a0) nounwind {
67 ; X32-LABEL: test_mm_cvtph_ps:
69 ; X32-NEXT: vcvtph2ps %xmm0, %xmm0
72 ; X64-LABEL: test_mm_cvtph_ps:
74 ; X64-NEXT: vcvtph2ps %xmm0, %xmm0
76 %arg0 = bitcast <2 x i64> %a0 to <8 x i16>
77 %res = call <4 x float> @llvm.x86.vcvtph2ps.128(<8 x i16> %arg0)
81 define <8 x float> @test_mm256_cvtph_ps(<2 x i64> %a0) nounwind {
82 ; X32-LABEL: test_mm256_cvtph_ps:
84 ; X32-NEXT: vcvtph2ps %xmm0, %ymm0
87 ; X64-LABEL: test_mm256_cvtph_ps:
89 ; X64-NEXT: vcvtph2ps %xmm0, %ymm0
91 %arg0 = bitcast <2 x i64> %a0 to <8 x i16>
92 %res = call <8 x float> @llvm.x86.vcvtph2ps.256(<8 x i16> %arg0)
96 define <2 x i64> @test_mm_cvtps_ph(<4 x float> %a0) nounwind {
97 ; X32-LABEL: test_mm_cvtps_ph:
99 ; X32-NEXT: vcvtps2ph $0, %xmm0, %xmm0
102 ; X64-LABEL: test_mm_cvtps_ph:
104 ; X64-NEXT: vcvtps2ph $0, %xmm0, %xmm0
106 %cvt = call <8 x i16> @llvm.x86.vcvtps2ph.128(<4 x float> %a0, i32 0)
107 %res = bitcast <8 x i16> %cvt to <2 x i64>
111 define <2 x i64> @test_mm256_cvtps_ph(<8 x float> %a0) nounwind {
112 ; X32-LABEL: test_mm256_cvtps_ph:
114 ; X32-NEXT: vcvtps2ph $0, %ymm0, %xmm0
115 ; X32-NEXT: vzeroupper
118 ; X64-LABEL: test_mm256_cvtps_ph:
120 ; X64-NEXT: vcvtps2ph $0, %ymm0, %xmm0
121 ; X64-NEXT: vzeroupper
123 %cvt = call <8 x i16> @llvm.x86.vcvtps2ph.256(<8 x float> %a0, i32 0)
124 %res = bitcast <8 x i16> %cvt to <2 x i64>
128 declare <4 x float> @llvm.x86.vcvtph2ps.128(<8 x i16>) nounwind readonly
129 declare <8 x float> @llvm.x86.vcvtph2ps.256(<8 x i16>) nounwind readonly
131 declare <8 x i16> @llvm.x86.vcvtps2ph.128(<4 x float>, i32) nounwind readonly
132 declare <8 x i16> @llvm.x86.vcvtps2ph.256(<8 x float>, i32) nounwind readonly