blob: 421d501a2ca9ac5ad89fe600553646714badf488 [file] [log] [blame]
Rafael Espindola2645d332014-12-22 13:29:46 +00001; RUN: llc < %s -march=arm | FileCheck %s
2
Dale Johannesenb42c1122007-05-10 01:04:28 +00003; Check that calls to baz and quux are tail-merged.
Rafael Espindola2645d332014-12-22 13:29:46 +00004; CHECK: bl _baz
5; CHECK-NOT: bl _baz
6; CHECK: bl _quux
7; CHECK-NOT: bl _quux
8
Duncan Sands6820abe2007-09-05 11:53:04 +00009; PR1628
Dale Johannesenb42c1122007-05-10 01:04:28 +000010
11; ModuleID = 'tail.c'
12target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64"
13target triple = "i686-apple-darwin8"
14
15define i32 @f(i32 %i, i32 %q) {
16entry:
17 %i_addr = alloca i32 ; <i32*> [#uses=2]
18 %q_addr = alloca i32 ; <i32*> [#uses=2]
19 %retval = alloca i32, align 4 ; <i32*> [#uses=1]
Dale Johannesenb42c1122007-05-10 01:04:28 +000020 store i32 %i, i32* %i_addr
21 store i32 %q, i32* %q_addr
David Blaikiea79ac142015-02-27 21:17:42 +000022 %tmp = load i32, i32* %i_addr ; <i32> [#uses=1]
Dale Johannesenb42c1122007-05-10 01:04:28 +000023 %tmp1 = icmp ne i32 %tmp, 0 ; <i1> [#uses=1]
24 %tmp12 = zext i1 %tmp1 to i8 ; <i8> [#uses=1]
25 %toBool = icmp ne i8 %tmp12, 0 ; <i1> [#uses=1]
26 br i1 %toBool, label %cond_true, label %cond_false
27
28cond_true: ; preds = %entry
David Blaikie23af6482015-04-16 23:24:18 +000029 %tmp3 = call i32 (...) @bar( ) ; <i32> [#uses=0]
30 %tmp4 = call i32 (...) @baz( i32 5, i32 6 ) ; <i32> [#uses=0]
David Blaikiea79ac142015-02-27 21:17:42 +000031 %tmp7 = load i32, i32* %q_addr ; <i32> [#uses=1]
Dale Johannesenb42c1122007-05-10 01:04:28 +000032 %tmp8 = icmp ne i32 %tmp7, 0 ; <i1> [#uses=1]
33 %tmp89 = zext i1 %tmp8 to i8 ; <i8> [#uses=1]
34 %toBool10 = icmp ne i8 %tmp89, 0 ; <i1> [#uses=1]
35 br i1 %toBool10, label %cond_true11, label %cond_false15
36
37cond_false: ; preds = %entry
David Blaikie23af6482015-04-16 23:24:18 +000038 %tmp5 = call i32 (...) @foo( ) ; <i32> [#uses=0]
39 %tmp6 = call i32 (...) @baz( i32 5, i32 6 ) ; <i32> [#uses=0]
David Blaikiea79ac142015-02-27 21:17:42 +000040 %tmp27 = load i32, i32* %q_addr ; <i32> [#uses=1]
Dale Johannesenb42c1122007-05-10 01:04:28 +000041 %tmp28 = icmp ne i32 %tmp27, 0 ; <i1> [#uses=1]
42 %tmp289 = zext i1 %tmp28 to i8 ; <i8> [#uses=1]
43 %toBool210 = icmp ne i8 %tmp289, 0 ; <i1> [#uses=1]
44 br i1 %toBool210, label %cond_true11, label %cond_false15
45
46cond_true11: ; preds = %cond_next
David Blaikie23af6482015-04-16 23:24:18 +000047 %tmp13 = call i32 (...) @foo( ) ; <i32> [#uses=0]
48 %tmp14 = call i32 (...) @quux( i32 3, i32 4 ) ; <i32> [#uses=0]
Dale Johannesenb42c1122007-05-10 01:04:28 +000049 br label %cond_next18
50
51cond_false15: ; preds = %cond_next
David Blaikie23af6482015-04-16 23:24:18 +000052 %tmp16 = call i32 (...) @bar( ) ; <i32> [#uses=0]
53 %tmp17 = call i32 (...) @quux( i32 3, i32 4 ) ; <i32> [#uses=0]
Dale Johannesenb42c1122007-05-10 01:04:28 +000054 br label %cond_next18
55
56cond_next18: ; preds = %cond_false15, %cond_true11
David Blaikie23af6482015-04-16 23:24:18 +000057 %tmp19 = call i32 (...) @bar( ) ; <i32> [#uses=0]
Dale Johannesenb42c1122007-05-10 01:04:28 +000058 br label %return
59
60return: ; preds = %cond_next18
David Blaikiea79ac142015-02-27 21:17:42 +000061 %retval20 = load i32, i32* %retval ; <i32> [#uses=1]
Dale Johannesenb42c1122007-05-10 01:04:28 +000062 ret i32 %retval20
63}
64
65declare i32 @bar(...)
66
67declare i32 @baz(...)
68
69declare i32 @foo(...)
70
71declare i32 @quux(...)