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 7 @g = common local_unnamed_addr global i8* null, align 8 8 9 define i8* @litp(i32 %a, i32 %b) { 10 entry: 11 %add = add nsw i32 %b, %a 12 %idx.ext = sext i32 %add to i64 13 %add.ptr = getelementptr i8, i8* bitcast (i8* (i32, i32)* @litp to i8*), i64 %idx.ext 14 store i8* %add.ptr, i8** @g, align 8 15 ret i8* %add.ptr 16 17 ; CHECK-LABEL: litp: 18 ; CHECK: adrp [[R:x[0-9]+]], litp 19 ; CHECKDONT-NEXT: add {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}} 20 ; CHECKFUSE-NEXT: add {{x[0-9]+}}, [[R]], :lo12:litp 21 } 22 23 define i32 @liti(i32 %a, i32 %b) { 24 entry: 25 %add = add i32 %a, -262095121 26 %add1 = add i32 %add, %b 27 ret i32 %add1 28 29 ; CHECK-LABEL: liti: 30 ; CHECK: mov [[R:w[0-9]+]], {{#[0-9]+}} 31 ; CHECKDONT-NEXT: add {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}} 32 ; CHECKFUSE-NEXT: movk [[R]], {{#[0-9]+}}, lsl #16 33 } 34 35 ; Function Attrs: norecurse nounwind readnone 36 define i64 @litl(i64 %a, i64 %b) { 37 entry: 38 %add = add i64 %a, 2208998440489107183 39 %add1 = add i64 %add, %b 40 ret i64 %add1 41 42 ; CHECK-LABEL: litl: 43 ; CHECK: mov [[R:x[0-9]+]], {{#[0-9]+}} 44 ; CHECK-NEXT: movk [[R]], {{#[0-9]+}}, lsl #16 45 ; CHECK: movk [[R]], {{#[0-9]+}}, lsl #32 46 ; CHECKDONT-NEXT: add {{x[0-9]+}}, {{x[0-9]+}}, {{x[0-9]+}} 47 ; CHECKFUSE-NEXT: movk [[R]], {{#[0-9]+}}, lsl #48 48 } 49