1 ; RUN: llc %s -o - -mtriple=aarch64-unknown -mattr=-fuse-adrp-add,-fuse-literals | FileCheck %s --check-prefix=CHECK --check-prefix=CHECKDONT
2 ; RUN: llc %s -o - -mtriple=aarch64-unknown -mattr=+fuse-adrp-add,+fuse-literals | FileCheck %s --check-prefix=CHECK --check-prefix=CHECKFUSE
3 ; RUN: llc %s -o - -mtriple=aarch64-unknown -mcpu=cortex-a57 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECKFUSE
4 ; RUN: llc %s -o - -mtriple=aarch64-unknown -mcpu=cortex-a65 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECKFUSE
5 ; RUN: llc %s -o - -mtriple=aarch64-unknown -mcpu=cortex-a72 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECKFUSE
6 ; RUN: llc %s -o - -mtriple=aarch64-unknown -mcpu=exynos-m3 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECKFUSE
7 ; RUN: llc %s -o - -mtriple=aarch64-unknown -mcpu=exynos-m4 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECKFUSE
8 ; RUN: llc %s -o - -mtriple=aarch64-unknown -mcpu=exynos-m5 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECKFUSE
9 ; RUN: llc %s -o - -mtriple=aarch64-unknown -mcpu=neoverse-n1 | FileCheck %s --check-prefix=CHECKFUSE-NEOVERSE
11 @g = common local_unnamed_addr global ptr null, align 8
13 define dso_local ptr @litp(i32 %a, i32 %b) {
15 %add = add nsw i32 %b, %a
16 %idx.ext = sext i32 %add to i64
17 %add.ptr = getelementptr i8, ptr @litp, i64 %idx.ext
18 store ptr %add.ptr, ptr @g, align 8
22 ; CHECK: adrp [[R:x[0-9]+]], litp
23 ; CHECKFUSE-NEXT: add {{x[0-9]+}}, [[R]], :lo12:litp
26 define dso_local ptr @litp_tune_generic(i32 %a, i32 %b) "tune-cpu"="generic" {
28 %add = add nsw i32 %b, %a
29 %idx.ext = sext i32 %add to i64
30 %add.ptr = getelementptr i8, ptr @litp_tune_generic, i64 %idx.ext
31 store ptr %add.ptr, ptr @g, align 8
34 ; CHECK-LABEL: litp_tune_generic:
35 ; CHECK: adrp [[R:x[0-9]+]], litp_tune_generic
36 ; CHECKDONT: add {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}
37 ; CHECK-NEXT: add {{x[0-9]+}}, [[R]], :lo12:litp_tune_generic
40 define dso_local ptr @litp_tune_neoverse_n1(i32 %a, i32 %b) "tune-cpu"="neoverse-n1" {
42 %add = add nsw i32 %b, %a
43 %idx.ext = sext i32 %add to i64
44 %add.ptr = getelementptr i8, ptr @litp_tune_generic, i64 %idx.ext
45 store ptr %add.ptr, ptr @g, align 8
48 ; CHECKFUSE-NEOVERSE-LABEL: litp_tune_neoverse_n1:
49 ; CHECKFUSE-NEOVERSE: adrp [[R:x[0-9]+]], litp_tune_generic
50 ; CHECKFUSE-NEOVERSE-NEXT: add {{x[0-9]+}}, [[R]], :lo12:litp_tune_generic
53 define dso_local i32 @liti(i32 %a, i32 %b) {
55 %add = add i32 %a, -262095121
56 %add1 = add i32 %add, %b
60 ; CHECK: mov [[R:w[0-9]+]], {{#[0-9]+}}
61 ; CHECKDONT-NEXT: add {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}
62 ; CHECKFUSE-NEXT: movk [[R]], {{#[0-9]+}}, lsl #16
65 ; Function Attrs: norecurse nounwind readnone
66 define dso_local i64 @litl(i64 %a, i64 %b) {
68 %add = add i64 %a, 2208998440489107183
69 %add1 = add i64 %add, %b
73 ; CHECK: mov [[R:x[0-9]+]], {{#[0-9]+}}
74 ; CHECKDONT-NEXT: add {{x[0-9]+}}, {{x[0-9]+}}, {{x[0-9]+}}
75 ; CHECK-NEXT: movk [[R]], {{#[0-9]+}}, lsl #16
76 ; CHECK: movk [[R]], {{#[0-9]+}}, lsl #32
77 ; CHECK-NEXT: movk [[R]], {{#[0-9]+}}, lsl #48
80 ; Function Attrs: norecurse nounwind readnone
81 define dso_local double @litf() {
83 ret double 0x400921FB54442D18
86 ; CHECK-DONT: adrp [[ADDR:x[0-9]+]], [[CSTLABEL:.LCP.*]]
87 ; CHECK-DONT-NEXT: ldr {{d[0-9]+}}, {{[[]}}[[ADDR]], :lo12:[[CSTLABEL]]{{[]]}}
88 ; CHECK-FUSE: mov [[R:x[0-9]+]], #11544
89 ; CHECK-FUSE: movk [[R]], #21572, lsl #16
90 ; CHECK-FUSE: movk [[R]], #8699, lsl #32
91 ; CHECK-FUSE: movk [[R]], #16393, lsl #48
92 ; CHECK-FUSE: fmov {{d[0-9]+}}, [[R]]