1 ; RUN: llc < %s -mtriple=arm-apple-darwin -relocation-model=dynamic-no-pic -mcpu=cortex-a8 -asm-verbose=false | FileCheck %s
12 declare i8* @choose(i8*, i8*)
14 ; BranchFolding should tail-duplicate the indirect jump to avoid
15 ; redundant branching.
17 ; CHECK-LABEL: tail_duplicate_me:
19 ; CHECK: movw r{{[0-9]+}}, :lower16:_GHJK
20 ; CHECK: movt r{{[0-9]+}}, :upper16:_GHJK
24 ; CHECK: movw r{{[0-9]+}}, :lower16:_GHJK
25 ; CHECK: movt r{{[0-9]+}}, :upper16:_GHJK
28 ; CHECK: movw r{{[0-9]+}}, :lower16:_GHJK
29 ; CHECK: movt r{{[0-9]+}}, :upper16:_GHJK
33 define void @tail_duplicate_me() nounwind {
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
41 br i1 %b, label %B, label %C
45 store i32 0, i32* @GHJK
50 store i32 0, i32* @GHJK
55 store i32 0, i32* @GHJK
59 indirectbr i8* %c, [label %return, label %altret]
62 call void @ear(i32 1000)
65 call void @far(i32 1001)
69 ; Use alternating abort functions so that the blocks we wish to merge are not
70 ; layout successors during branch folding.
72 ; CHECK-LABEL: merge_alternating_aborts:
74 ; CHECK-NOT: _alt_abort
77 ; CHECK-NOT: _alt_abort
82 ; CHECK-NOT: _alt_abort
87 ; CHECK-NOT: _alt_abort
90 declare void @alt_abort()
92 define void @merge_alternating_aborts() {
95 br i1 %c1, label %cont1, label %abort1
101 br i1 %c2, label %cont2, label %abort2
103 call void @alt_abort()
107 br i1 %c3, label %cont3, label %abort3
113 br i1 %c4, label %cont4, label %abort4
115 call void @alt_abort()