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=exynos-m3 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECKFUSE
5 ; RUN: llc %s -o - -mtriple=aarch64-unknown -mcpu=exynos-m4 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECKFUSE
6 ; RUN: llc %s -o - -mtriple=aarch64-unknown -mcpu=exynos-m5 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECKFUSE
8 @g = common local_unnamed_addr global i8* null, align 8
10 define i8* @litp(i32 %a, i32 %b) {
12 %add = add nsw i32 %b, %a
13 %idx.ext = sext i32 %add to i64
14 %add.ptr = getelementptr i8, i8* bitcast (i8* (i32, i32)* @litp to i8*), i64 %idx.ext
15 store i8* %add.ptr, i8** @g, align 8
19 ; CHECK: adrp [[R:x[0-9]+]], litp
20 ; CHECKDONT-NEXT: add {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}
21 ; CHECKFUSE-NEXT: add {{x[0-9]+}}, [[R]], :lo12:litp
24 define i32 @liti(i32 %a, i32 %b) {
26 %add = add i32 %a, -262095121
27 %add1 = add i32 %add, %b
31 ; CHECK: mov [[R:w[0-9]+]], {{#[0-9]+}}
32 ; CHECKDONT-NEXT: add {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}
33 ; CHECKFUSE-NEXT: movk [[R]], {{#[0-9]+}}, lsl #16
36 ; Function Attrs: norecurse nounwind readnone
37 define i64 @litl(i64 %a, i64 %b) {
39 %add = add i64 %a, 2208998440489107183
40 %add1 = add i64 %add, %b
44 ; CHECK: mov [[R:x[0-9]+]], {{#[0-9]+}}
45 ; CHECK-NEXT: movk [[R]], {{#[0-9]+}}, lsl #16
46 ; CHECK: movk [[R]], {{#[0-9]+}}, lsl #32
47 ; CHECKDONT-NEXT: add {{x[0-9]+}}, {{x[0-9]+}}, {{x[0-9]+}}
48 ; CHECKFUSE-NEXT: movk [[R]], {{#[0-9]+}}, lsl #48
51 ; Function Attrs: norecurse nounwind readnone
52 define double @litf() {
54 ret double 0x400921FB54442D18
57 ; CHECK-DONT: adrp [[ADDR:x[0-9]+]], [[CSTLABEL:.LCP.*]]
58 ; CHECK-DONT-NEXT: ldr {{d[0-9]+}}, {{[[]}}[[ADDR]], :lo12:[[CSTLABEL]]{{[]]}}
59 ; CHECK-FUSE: mov [[R:x[0-9]+]], #11544
60 ; CHECK-FUSE: movk [[R]], #21572, lsl #16
61 ; CHECK-FUSE: movk [[R]], #8699, lsl #32
62 ; CHECK-FUSE: movk [[R]], #16393, lsl #48
63 ; CHECK-FUSE: fmov {{d[0-9]+}}, [[R]]