• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc < %s -mtriple=arm-apple-darwin -relocation-model=dynamic-no-pic -mcpu=cortex-a8 -asm-verbose=false | FileCheck %s
2
3declare void @bar(i32)
4declare void @car(i32)
5declare void @dar(i32)
6declare void @ear(i32)
7declare void @far(i32)
8declare i1 @qux()
9
10@GHJK = global i32 0
11
12declare i8* @choose(i8*, i8*)
13
14; BranchFolding should tail-duplicate the indirect jump to avoid
15; redundant branching.
16
17; CHECK-LABEL: tail_duplicate_me:
18; CHECK:      qux
19; CHECK:      movw r{{[0-9]+}}, :lower16:_GHJK
20; CHECK:      movt r{{[0-9]+}}, :upper16:_GHJK
21; CHECK:      str r
22; CHECK-NEXT: bx r
23; CHECK:      qux
24; CHECK:      movw r{{[0-9]+}}, :lower16:_GHJK
25; CHECK:      movt r{{[0-9]+}}, :upper16:_GHJK
26; CHECK:      str r
27; CHECK-NEXT: bx r
28; CHECK:      movw r{{[0-9]+}}, :lower16:_GHJK
29; CHECK:      movt r{{[0-9]+}}, :upper16:_GHJK
30; CHECK:      str r
31; CHECK-NEXT: bx r
32
33define void @tail_duplicate_me() nounwind {
34entry:
35  %a = call i1 @qux()
36  %c = call i8* @choose(i8* blockaddress(@tail_duplicate_me, %return),
37                        i8* blockaddress(@tail_duplicate_me, %altret))
38  br i1 %a, label %A, label %next
39next:
40  %b = call i1 @qux()
41  br i1 %b, label %B, label %C
42
43A:
44  call void @bar(i32 0)
45  store i32 0, i32* @GHJK
46  br label %M
47
48B:
49  call void @car(i32 1)
50  store i32 0, i32* @GHJK
51  br label %M
52
53C:
54  call void @dar(i32 2)
55  store i32 0, i32* @GHJK
56  br label %M
57
58M:
59  indirectbr i8* %c, [label %return, label %altret]
60
61return:
62  call void @ear(i32 1000)
63  ret void
64altret:
65  call void @far(i32 1001)
66  ret void
67}
68