Enable sibling call optimization of libcalls which are expanded during
[oota-llvm.git] / test / CodeGen / ARM / call-tc.ll
1 ; RUN: llc < %s -mtriple=armv6-apple-darwin -mattr=+vfp2 -arm-tail-calls | FileCheck %s -check-prefix=CHECKV6
2 ; RUN: llc < %s -mtriple=armv6-linux-gnueabi -relocation-model=pic -mattr=+vfp2 -arm-tail-calls | FileCheck %s -check-prefix=CHECKELF
3
4 @t = weak global i32 ()* null           ; <i32 ()**> [#uses=1]
5
6 declare void @g(i32, i32, i32, i32)
7
8 define void @t1() {
9 ; CHECKELF: t1:
10 ; CHECKELF: bl g(PLT)
11         call void @g( i32 1, i32 2, i32 3, i32 4 )
12         ret void
13 }
14
15 define void @t2() {
16 ; CHECKV6: t2:
17 ; CHECKV6: bx r0 @ TAILCALL
18         %tmp = load i32 ()** @t         ; <i32 ()*> [#uses=1]
19         %tmp.upgrd.2 = tail call i32 %tmp( )            ; <i32> [#uses=0]
20         ret void
21 }
22
23 define void @t3() {
24 ; CHECKV6: t3:
25 ; CHECKV6: b _t2  @ TAILCALL
26 ; CHECKELF: t3:
27 ; CHECKELF: b t2(PLT) @ TAILCALL
28         tail call void @t2( )            ; <i32> [#uses=0]
29         ret void
30 }
31
32 ; Sibcall optimization of expanded libcalls. rdar://8707777
33 define double @t4(double %a) nounwind readonly ssp {
34 entry:
35 ; CHECKV6: t4:
36 ; CHECKV6: b _sin @ TAILCALL
37 ; CHECKELF: t4:
38 ; CHECKELF: b sin(PLT) @ TAILCALL
39   %0 = tail call double @sin(double %a) nounwind readonly ; <double> [#uses=1]
40   ret double %0
41 }
42
43 define float @t5(float %a) nounwind readonly ssp {
44 entry:
45 ; CHECKV6: t5:
46 ; CHECKV6: b _sinf @ TAILCALL
47 ; CHECKELF: t5:
48 ; CHECKELF: b sinf(PLT) @ TAILCALL
49   %0 = tail call float @sinf(float %a) nounwind readonly ; <float> [#uses=1]
50   ret float %0
51 }
52
53 declare float @sinf(float) nounwind readonly
54
55 declare double @sin(double) nounwind readonly
56
57 define i32 @t6(i32 %a, i32 %b) nounwind readnone {
58 entry:
59 ; CHECKV6: t6:
60 ; CHECKV6: b ___divsi3 @ TAILCALL
61 ; CHECKELF: t6:
62 ; CHECKELF: b __aeabi_idiv(PLT) @ TAILCALL
63   %0 = sdiv i32 %a, %b
64   ret i32 %0
65 }