1 ; RUN: llc %s -o - -mtriple=aarch64-unknown -mattr=-fuse-literals | FileCheck %s --check-prefix=CHECK --check-prefix=CHECKDONT
2 ; RUN: llc %s -o - -mtriple=aarch64-unknown -mattr=+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
10 @g = common local_unnamed_addr global i8* null, align 8
12 define dso_local i8* @litp(i32 %a, i32 %b) {
14 %add = add nsw i32 %b, %a
15 %idx.ext = sext i32 %add to i64
16 %add.ptr = getelementptr i8, i8* bitcast (i8* (i32, i32)* @litp to i8*), i64 %idx.ext
17 store i8* %add.ptr, i8** @g, align 8
21 ; CHECK: adrp [[R:x[0-9]+]], litp
22 ; CHECKDONT-NEXT: add {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}
23 ; CHECKFUSE-NEXT: add {{x[0-9]+}}, [[R]], :lo12:litp
26 define dso_local i32 @liti(i32 %a, i32 %b) {
28 %add = add i32 %a, -262095121
29 %add1 = add i32 %add, %b
33 ; CHECK: mov [[R:w[0-9]+]], {{#[0-9]+}}
34 ; CHECKDONT-NEXT: add {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}
35 ; CHECKFUSE-NEXT: movk [[R]], {{#[0-9]+}}, lsl #16
38 ; Function Attrs: norecurse nounwind readnone
39 define dso_local i64 @litl(i64 %a, i64 %b) {
41 %add = add i64 %a, 2208998440489107183
42 %add1 = add i64 %add, %b
46 ; CHECK: mov [[R:x[0-9]+]], {{#[0-9]+}}
47 ; CHECK-NEXT: movk [[R]], {{#[0-9]+}}, lsl #16
48 ; CHECK: movk [[R]], {{#[0-9]+}}, lsl #32
49 ; CHECKDONT-NEXT: add {{x[0-9]+}}, {{x[0-9]+}}, {{x[0-9]+}}
50 ; CHECKFUSE-NEXT: movk [[R]], {{#[0-9]+}}, lsl #48
53 ; Function Attrs: norecurse nounwind readnone
54 define dso_local double @litf() {
56 ret double 0x400921FB54442D18
59 ; CHECK-DONT: adrp [[ADDR:x[0-9]+]], [[CSTLABEL:.LCP.*]]
60 ; CHECK-DONT-NEXT: ldr {{d[0-9]+}}, {{[[]}}[[ADDR]], :lo12:[[CSTLABEL]]{{[]]}}
61 ; CHECK-FUSE: mov [[R:x[0-9]+]], #11544
62 ; CHECK-FUSE: movk [[R]], #21572, lsl #16
63 ; CHECK-FUSE: movk [[R]], #8699, lsl #32
64 ; CHECK-FUSE: movk [[R]], #16393, lsl #48
65 ; CHECK-FUSE: fmov {{d[0-9]+}}, [[R]]