1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=aarch64-none-linux -O2 < %s | FileCheck %s --check-prefix=CHECK-O2
3 ; RUN: llc -mtriple=aarch64-none-linux -O3 < %s | FileCheck %s --check-prefix=CHECK-O3
5 ; RUN: llc -mtriple=aarch64-none-linux -tail-dup-size=4 < %s | FileCheck %s --check-prefix=CHECK-O2
6 ; RUN: llc -mtriple=aarch64-none-linux -tail-dup-placement-threshold=4 < %s | FileCheck %s --check-prefix=CHECK-O2
7 ; RUN: llc -mtriple=aarch64-none-linux -tail-dup-placement-threshold=6 < %s | FileCheck %s --check-prefix=CHECK-O3
9 %a = type { %a*, i32, %b }
11 %c = type { i32, i32, [31 x i8] }
13 @global_ptr = dso_local local_unnamed_addr global %a* null, align 8
14 @global_int = dso_local local_unnamed_addr global i32 0, align 4
16 define dso_local void @testcase(%a** nocapture %arg){
17 ; CHECK-O2-LABEL: testcase:
18 ; CHECK-O2: // %bb.0: // %entry
19 ; CHECK-O2-NEXT: adrp x8, global_ptr
20 ; CHECK-O2-NEXT: ldr x9, [x8, :lo12:global_ptr]
21 ; CHECK-O2-NEXT: cbz x9, .LBB0_2
22 ; CHECK-O2-NEXT: // %bb.1: // %if.then
23 ; CHECK-O2-NEXT: ldr x9, [x9]
24 ; CHECK-O2-NEXT: str x9, [x0]
25 ; CHECK-O2-NEXT: ldr x8, [x8, :lo12:global_ptr]
26 ; CHECK-O2-NEXT: b .LBB0_3
27 ; CHECK-O2-NEXT: .LBB0_2:
28 ; CHECK-O2-NEXT: mov x8, xzr
29 ; CHECK-O2-NEXT: .LBB0_3: // %if.end
30 ; CHECK-O2-NEXT: adrp x9, global_int
31 ; CHECK-O2-NEXT: ldr w1, [x9, :lo12:global_int]
32 ; CHECK-O2-NEXT: add x2, x8, #16
33 ; CHECK-O2-NEXT: mov w0, #10
34 ; CHECK-O2-NEXT: b externalfunc
36 ; CHECK-O3-LABEL: testcase:
37 ; CHECK-O3: // %bb.0: // %entry
38 ; CHECK-O3-NEXT: adrp x8, global_ptr
39 ; CHECK-O3-NEXT: ldr x9, [x8, :lo12:global_ptr]
40 ; CHECK-O3-NEXT: cbz x9, .LBB0_2
41 ; CHECK-O3-NEXT: // %bb.1: // %if.then
42 ; CHECK-O3-NEXT: ldr x9, [x9]
43 ; CHECK-O3-NEXT: str x9, [x0]
44 ; CHECK-O3-NEXT: ldr x8, [x8, :lo12:global_ptr]
45 ; CHECK-O3-NEXT: adrp x9, global_int
46 ; CHECK-O3-NEXT: ldr w1, [x9, :lo12:global_int]
47 ; CHECK-O3-NEXT: add x2, x8, #16
48 ; CHECK-O3-NEXT: mov w0, #10
49 ; CHECK-O3-NEXT: b externalfunc
50 ; CHECK-O3-NEXT: .LBB0_2:
51 ; CHECK-O3-NEXT: mov x8, xzr
52 ; CHECK-O3-NEXT: adrp x9, global_int
53 ; CHECK-O3-NEXT: ldr w1, [x9, :lo12:global_int]
54 ; CHECK-O3-NEXT: add x2, x8, #16
55 ; CHECK-O3-NEXT: mov w0, #10
56 ; CHECK-O3-NEXT: b externalfunc
58 %0 = load %a*, %a** @global_ptr, align 8
59 %cmp.not = icmp eq %a* %0, null
60 br i1 %cmp.not, label %if.end, label %if.then
62 if.then: ; preds = %entry
63 %1 = getelementptr inbounds %a, %a* %0, i64 0, i32 0
64 %2 = load %a*, %a** %1, align 8
65 store %a* %2, %a** %arg, align 8
66 %.pre = load %a*, %a** @global_ptr, align 8
69 if.end: ; preds = %if.then, %entry
70 %3 = phi %a* [ %.pre, %if.then ], [ null, %entry ]
71 %4 = load i32, i32* @global_int, align 4
72 %5 = getelementptr inbounds %a, %a* %3, i64 0, i32 2, i32 0, i32 1
73 tail call void @externalfunc(i32 10, i32 %4, i32* nonnull %5)
77 declare dso_local void @externalfunc(i32, i32, i32*)