ARM64: initial backend import
[oota-llvm.git] / test / CodeGen / ARM64 / collect-loh.ll
1 ; RUN: llc -mtriple=arm64-apple-ios -O2 -arm64-collect-loh -arm64-collect-loh-bb-only=false < %s -o - | FileCheck %s
2
3 @a = internal unnamed_addr global i32 0, align 4
4 @b = external global i32
5
6 ; Function Attrs: noinline nounwind ssp
7 define void @foo(i32 %t) {
8 entry:
9   %tmp = load i32* @a, align 4
10   %add = add nsw i32 %tmp, %t
11   store i32 %add, i32* @a, align 4
12   ret void
13 }
14
15 ; Function Attrs: nounwind ssp
16 ; Testcase for <rdar://problem/15438605>, AdrpAdrp reuse is valid only when the first adrp
17 ; dominates the second.
18 ; The first adrp comes from the loading of 'a' and the second the loading of 'b'.
19 ; 'a' is loaded in if.then, 'b' in if.end4, if.then does not dominates if.end4.
20 ; CHECK-LABEL: _test
21 ; CHECK: ret
22 ; CHECK-NOT: .loh AdrpAdrp
23 define i32 @test(i32 %t) {
24 entry:
25   %cmp = icmp sgt i32 %t, 5
26   br i1 %cmp, label %if.then, label %if.end4
27
28 if.then:                                          ; preds = %entry
29   %tmp = load i32* @a, align 4
30   %add = add nsw i32 %tmp, %t
31   %cmp1 = icmp sgt i32 %add, 12
32   br i1 %cmp1, label %if.then2, label %if.end4
33
34 if.then2:                                         ; preds = %if.then
35   tail call void @foo(i32 %add)
36   %tmp1 = load i32* @a, align 4
37   br label %if.end4
38
39 if.end4:                                          ; preds = %if.then2, %if.then, %entry
40   %t.addr.0 = phi i32 [ %tmp1, %if.then2 ], [ %t, %if.then ], [ %t, %entry ]
41   %tmp2 = load i32* @b, align 4
42   %add5 = add nsw i32 %tmp2, %t.addr.0
43   tail call void @foo(i32 %add5)
44   %tmp3 = load i32* @b, align 4
45   %add6 = add nsw i32 %tmp3, %t.addr.0
46   ret i32 %add6
47 }