xref: /minix3/external/bsd/llvm/dist/llvm/test/CodeGen/X86/half.ll (revision bdb565187c0f1a04513dd488df843317b27f86c8)
1; RUN: llc < %s -march=x86-64 -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -mattr=-f16c | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-LIBCALL
2; RUN: llc < %s -march=x86-64 -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -mattr=+f16c | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-F16C
3
4define void @test_load_store(half* %in, half* %out) {
5; CHECK-LABEL: test_load_store:
6; CHECK: movw (%rdi), [[TMP:%[a-z0-9]+]]
7; CHECK: movw [[TMP]], (%rsi)
8  %val = load half* %in
9  store half %val, half* %out
10  ret void
11}
12
13define i16 @test_bitcast_from_half(half* %addr) {
14; CHECK-LABEL: test_bitcast_from_half:
15; CHECK: movzwl (%rdi), %eax
16  %val = load half* %addr
17  %val_int = bitcast half %val to i16
18  ret i16 %val_int
19}
20
21define void @test_bitcast_to_half(half* %addr, i16 %in) {
22; CHECK-LABEL: test_bitcast_to_half:
23; CHECK: movw %si, (%rdi)
24  %val_fp = bitcast i16 %in to half
25  store half %val_fp, half* %addr
26  ret void
27}
28
29define float @test_extend32(half* %addr) {
30; CHECK-LABEL: test_extend32:
31
32; CHECK-LIBCALL: jmp __gnu_h2f_ieee
33; CHECK-FP16: vcvtph2ps
34  %val16 = load half* %addr
35  %val32 = fpext half %val16 to float
36  ret float %val32
37}
38
39define double @test_extend64(half* %addr) {
40; CHECK-LABEL: test_extend64:
41
42; CHECK-LIBCALL: callq __gnu_h2f_ieee
43; CHECK-LIBCALL: cvtss2sd
44; CHECK-FP16: vcvtph2ps
45; CHECK-FP16: vcvtss2sd
46  %val16 = load half* %addr
47  %val32 = fpext half %val16 to double
48  ret double %val32
49}
50
51define void @test_trunc32(float %in, half* %addr) {
52; CHECK-LABEL: test_trunc32:
53
54; CHECK-LIBCALL: callq __gnu_f2h_ieee
55; CHECK-FP16: vcvtps2ph
56  %val16 = fptrunc float %in to half
57  store half %val16, half* %addr
58  ret void
59}
60
61define void @test_trunc64(double %in, half* %addr) {
62; CHECK-LABEL: test_trunc64:
63
64; CHECK-LIBCALL: callq __truncdfhf2
65; CHECK-FP16: callq __truncdfhf2
66  %val16 = fptrunc double %in to half
67  store half %val16, half* %addr
68  ret void
69}
70