AArch64: support f16 extend/trunc operations.
[oota-llvm.git] / test / CodeGen / AArch64 / half.ll
1 ; RUN: llc < %s -mtriple=arm64-apple-ios7.0 | FileCheck %s
2
3 define void @test_load_store(half* %in, half* %out) {
4 ; CHECK-LABEL: test_load_store:
5 ; CHECK: ldr [[TMP:h[0-9]+]], [x0]
6 ; CHECK: str [[TMP]], [x1]
7   %val = load half* %in
8   store half %val, half* %out
9   ret void
10 }
11
12 define i16 @test_bitcast_from_half(half* %addr) {
13 ; CHECK-LABEL: test_bitcast_from_half:
14 ; CHECK: ldrh w0, [x0]
15   %val = load half* %addr
16   %val_int = bitcast half %val to i16
17   ret i16 %val_int
18 }
19
20 define void @test_bitcast_to_half(half* %addr, i16 %in) {
21 ; CHECK-LABEL: test_bitcast_to_half:
22 ; CHECK: strh w1, [x0]
23   %val_fp = bitcast i16 %in to half
24   store half %val_fp, half* %addr
25   ret void
26 }
27
28 define float @test_extend32(half* %addr) {
29 ; CHECK-LABEL: test_extend32:
30 ; CHECK: fcvt {{s[0-9]+}}, {{h[0-9]+}}
31
32   %val16 = load half* %addr
33   %val32 = fpext half %val16 to float
34   ret float %val32
35 }
36
37 define double @test_extend64(half* %addr) {
38 ; CHECK-LABEL: test_extend64:
39 ; CHECK: fcvt {{d[0-9]+}}, {{h[0-9]+}}
40
41   %val16 = load half* %addr
42   %val32 = fpext half %val16 to double
43   ret double %val32
44 }
45
46 define void @test_trunc32(float %in, half* %addr) {
47 ; CHECK-LABEL: test_trunc32:
48 ; CHECK: fcvt {{h[0-9]+}}, {{s[0-9]+}}
49
50   %val16 = fptrunc float %in to half
51   store half %val16, half* %addr
52   ret void
53 }
54
55 define void @test_trunc64(double %in, half* %addr) {
56 ; CHECK-LABEL: test_trunc64:
57 ; CHECK: fcvt {{h[0-9]+}}, {{d[0-9]+}}
58
59   %val16 = fptrunc double %in to half
60   store half %val16, half* %addr
61   ret void
62 }