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 { ptr, i32, %b }
11 %c = type { i32, i32, [31 x i8] }
13 @global_ptr = dso_local local_unnamed_addr global ptr null, align 8
14 @global_int = dso_local local_unnamed_addr global i32 0, align 4
16 define dso_local void @testcase(ptr 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: add x2, x8, #16
32 ; CHECK-O2-NEXT: mov w0, #10
33 ; CHECK-O2-NEXT: ldr w1, [x9, :lo12:global_int]
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: add x2, x8, #16
47 ; CHECK-O3-NEXT: mov w0, #10
48 ; CHECK-O3-NEXT: ldr w1, [x9, :lo12:global_int]
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: add x2, x8, #16
54 ; CHECK-O3-NEXT: mov w0, #10
55 ; CHECK-O3-NEXT: ldr w1, [x9, :lo12:global_int]
56 ; CHECK-O3-NEXT: b externalfunc
58 %0 = load ptr, ptr @global_ptr, align 8
59 %cmp.not = icmp eq ptr %0, null
60 br i1 %cmp.not, label %if.end, label %if.then
62 if.then: ; preds = %entry
63 %1 = load ptr, ptr %0, align 8
64 store ptr %1, ptr %arg, align 8
65 %.pre = load ptr, ptr @global_ptr, align 8
68 if.end: ; preds = %if.then, %entry
69 %2 = phi ptr [ %.pre, %if.then ], [ null, %entry ]
70 %3 = load i32, ptr @global_int, align 4
71 %4 = getelementptr inbounds %a, ptr %2, i64 0, i32 2, i32 0, i32 1
72 tail call void @externalfunc(i32 10, i32 %3, ptr nonnull %4)
76 declare dso_local void @externalfunc(i32, i32, ptr)