Guard fabs to bfc convert with V6T2 flag
[oota-llvm.git] / test / CodeGen / ARM / half.ll
1 ; RUN: llc < %s -mtriple=thumbv7-apple-ios7.0 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-OLD
2 ; RUN: llc < %s -mtriple=thumbv7s-apple-ios7.0 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-F16
3 ; RUN: llc < %s -mtriple=thumbv8-apple-ios7.0 | FileCheck %s --check-prefix=CHECK  --check-prefix=CHECK-V8
4
5 define void @test_load_store(half* %in, half* %out) {
6 ; CHECK-LABEL: test_load_store:
7 ; CHECK: ldrh [[TMP:r[0-9]+]], [r0]
8 ; CHECK: strh [[TMP]], [r1]
9   %val = load half, half* %in
10   store half %val, half* %out
11   ret void
12 }
13
14 define i16 @test_bitcast_from_half(half* %addr) {
15 ; CHECK-LABEL: test_bitcast_from_half:
16 ; CHECK: ldrh r0, [r0]
17   %val = load half, half* %addr
18   %val_int = bitcast half %val to i16
19   ret i16 %val_int
20 }
21
22 define void @test_bitcast_to_half(half* %addr, i16 %in) {
23 ; CHECK-LABEL: test_bitcast_to_half:
24 ; CHECK: strh r1, [r0]
25   %val_fp = bitcast i16 %in to half
26   store half %val_fp, half* %addr
27   ret void
28 }
29
30 define float @test_extend32(half* %addr) {
31 ; CHECK-LABEL: test_extend32:
32
33 ; CHECK-OLD: b.w ___extendhfsf2
34 ; CHECK-F16: vcvtb.f32.f16
35 ; CHECK-V8: vcvtb.f32.f16
36   %val16 = load half, half* %addr
37   %val32 = fpext half %val16 to float
38   ret float %val32
39 }
40
41 define double @test_extend64(half* %addr) {
42 ; CHECK-LABEL: test_extend64:
43
44 ; CHECK-OLD: blx ___extendhfsf2
45 ; CHECK-OLD: vcvt.f64.f32
46 ; CHECK-F16: vcvtb.f32.f16
47 ; CHECK-F16: vcvt.f64.f32
48 ; CHECK-V8: vcvtb.f64.f16
49   %val16 = load half, half* %addr
50   %val32 = fpext half %val16 to double
51   ret double %val32
52 }
53
54 define void @test_trunc32(float %in, half* %addr) {
55 ; CHECK-LABEL: test_trunc32:
56
57 ; CHECK-OLD: blx ___truncsfhf2
58 ; CHECK-F16: vcvtb.f16.f32
59 ; CHECK-V8: vcvtb.f16.f32
60   %val16 = fptrunc float %in to half
61   store half %val16, half* %addr
62   ret void
63 }
64
65 define void @test_trunc64(double %in, half* %addr) {
66 ; CHECK-LABEL: test_trunc64:
67
68 ; CHECK-OLD: blx ___truncdfhf2
69 ; CHECK-F16: blx ___truncdfhf2
70 ; CHECK-V8: vcvtb.f16.f64
71   %val16 = fptrunc double %in to half
72   store half %val16, half* %addr
73   ret void
74 }