blob: 7669a03c969a35671632ff99e17316eeaa9da6ce [file] [log] [blame]
Matthias Braun7c913362017-08-01 22:20:49 +00001; RUN: llc < %s | FileCheck %s
2; RUN: llc < %s -enable-tail-merge=0 | FileCheck --check-prefix=NOMERGE %s
Rafael Espindola2645d332014-12-22 13:29:46 +00003
4; Check that tail merging is the default on ARM, and that -enable-tail-merge=0
5; works.
Duncan Sands6820abe2007-09-05 11:53:04 +00006; PR1628
Dale Johannesena7120dd2007-05-22 17:19:23 +00007
Rafael Espindola2645d332014-12-22 13:29:46 +00008; CHECK: bl _baz
9; CHECK-NOT: bl _baz
10
11; CHECK: bl _quux
12; CHECK-NOT: bl _quux
13
Kyle Butt7fbec9b2017-02-15 19:49:14 +000014; NOMERGE-DAG: bl _baz
15; NOMERGE-DAG: bl _baz
Rafael Espindola2645d332014-12-22 13:29:46 +000016
Kyle Butt7fbec9b2017-02-15 19:49:14 +000017; NOMERGE-DAG: bl _quux
18; NOMERGE-DAG: bl _quux
Rafael Espindola2645d332014-12-22 13:29:46 +000019
Dale Johannesena7120dd2007-05-22 17:19:23 +000020; ModuleID = 'tail.c'
21target 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"
Matthias Braun7c913362017-08-01 22:20:49 +000022target triple = "arm-apple-darwin8"
Dale Johannesena7120dd2007-05-22 17:19:23 +000023
24define i32 @f(i32 %i, i32 %q) {
25entry:
26 %i_addr = alloca i32 ; <i32*> [#uses=2]
27 %q_addr = alloca i32 ; <i32*> [#uses=2]
28 %retval = alloca i32, align 4 ; <i32*> [#uses=1]
Dale Johannesena7120dd2007-05-22 17:19:23 +000029 store i32 %i, i32* %i_addr
30 store i32 %q, i32* %q_addr
David Blaikiea79ac142015-02-27 21:17:42 +000031 %tmp = load i32, i32* %i_addr ; <i32> [#uses=1]
Dale Johannesena7120dd2007-05-22 17:19:23 +000032 %tmp1 = icmp ne i32 %tmp, 0 ; <i1> [#uses=1]
33 %tmp12 = zext i1 %tmp1 to i8 ; <i8> [#uses=1]
34 %toBool = icmp ne i8 %tmp12, 0 ; <i1> [#uses=1]
35 br i1 %toBool, label %cond_true, label %cond_false
36
37cond_true: ; preds = %entry
David Blaikie23af6482015-04-16 23:24:18 +000038 %tmp3 = call i32 (...) @bar( ) ; <i32> [#uses=0]
39 %tmp4 = call i32 (...) @baz( i32 5, i32 6 ) ; <i32> [#uses=0]
David Blaikiea79ac142015-02-27 21:17:42 +000040 %tmp7 = load i32, i32* %q_addr ; <i32> [#uses=1]
Dale Johannesena7120dd2007-05-22 17:19:23 +000041 %tmp8 = icmp ne i32 %tmp7, 0 ; <i1> [#uses=1]
42 %tmp89 = zext i1 %tmp8 to i8 ; <i8> [#uses=1]
43 %toBool10 = icmp ne i8 %tmp89, 0 ; <i1> [#uses=1]
44 br i1 %toBool10, label %cond_true11, label %cond_false15
45
46cond_false: ; preds = %entry
David Blaikie23af6482015-04-16 23:24:18 +000047 %tmp5 = call i32 (...) @foo( ) ; <i32> [#uses=0]
48 %tmp6 = call i32 (...) @baz( i32 5, i32 6 ) ; <i32> [#uses=0]
David Blaikiea79ac142015-02-27 21:17:42 +000049 %tmp27 = load i32, i32* %q_addr ; <i32> [#uses=1]
Dale Johannesena7120dd2007-05-22 17:19:23 +000050 %tmp28 = icmp ne i32 %tmp27, 0 ; <i1> [#uses=1]
51 %tmp289 = zext i1 %tmp28 to i8 ; <i8> [#uses=1]
52 %toBool210 = icmp ne i8 %tmp289, 0 ; <i1> [#uses=1]
53 br i1 %toBool210, label %cond_true11, label %cond_false15
54
55cond_true11: ; preds = %cond_next
David Blaikie23af6482015-04-16 23:24:18 +000056 %tmp13 = call i32 (...) @foo( ) ; <i32> [#uses=0]
57 %tmp14 = call i32 (...) @quux( i32 3, i32 4 ) ; <i32> [#uses=0]
Dale Johannesena7120dd2007-05-22 17:19:23 +000058 br label %cond_next18
59
60cond_false15: ; preds = %cond_next
David Blaikie23af6482015-04-16 23:24:18 +000061 %tmp16 = call i32 (...) @bar( ) ; <i32> [#uses=0]
62 %tmp17 = call i32 (...) @quux( i32 3, i32 4 ) ; <i32> [#uses=0]
Dale Johannesena7120dd2007-05-22 17:19:23 +000063 br label %cond_next18
64
65cond_next18: ; preds = %cond_false15, %cond_true11
David Blaikie23af6482015-04-16 23:24:18 +000066 %tmp19 = call i32 (...) @bar( ) ; <i32> [#uses=0]
Dale Johannesena7120dd2007-05-22 17:19:23 +000067 br label %return
68
69return: ; preds = %cond_next18
David Blaikiea79ac142015-02-27 21:17:42 +000070 %retval20 = load i32, i32* %retval ; <i32> [#uses=1]
Dale Johannesena7120dd2007-05-22 17:19:23 +000071 ret i32 %retval20
72}
73
74declare i32 @bar(...)
75
76declare i32 @baz(...)
77
78declare i32 @foo(...)
79
80declare i32 @quux(...)