1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s | FileCheck %s --check-prefix=RV32I
3 ; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s | FileCheck %s --check-prefix=RV64I
5 ; This test case test the LocalStackSlotAllocation pass that use a base register
6 ; for the frame index that its offset is out-of-range (for RISC-V. the immediate
7 ; is 12 bits for the load store instruction (excludes vector load / store))
8 define void @use_frame_base_reg() {
9 ; RV32I-LABEL: use_frame_base_reg:
11 ; RV32I-NEXT: lui a0, 24
12 ; RV32I-NEXT: addi a0, a0, 1712
13 ; RV32I-NEXT: sub sp, sp, a0
14 ; RV32I-NEXT: .cfi_def_cfa_offset 100016
15 ; RV32I-NEXT: lui a0, 24
16 ; RV32I-NEXT: addi a0, a0, 1704
17 ; RV32I-NEXT: add a0, sp, a0
18 ; RV32I-NEXT: lbu zero, 4(a0)
19 ; RV32I-NEXT: lbu zero, 0(a0)
20 ; RV32I-NEXT: lui a0, 24
21 ; RV32I-NEXT: addi a0, a0, 1712
22 ; RV32I-NEXT: add sp, sp, a0
25 ; RV64I-LABEL: use_frame_base_reg:
27 ; RV64I-NEXT: lui a0, 24
28 ; RV64I-NEXT: addiw a0, a0, 1712
29 ; RV64I-NEXT: sub sp, sp, a0
30 ; RV64I-NEXT: .cfi_def_cfa_offset 100016
31 ; RV64I-NEXT: lui a0, 24
32 ; RV64I-NEXT: addiw a0, a0, 1704
33 ; RV64I-NEXT: add a0, sp, a0
34 ; RV64I-NEXT: lbu zero, 4(a0)
35 ; RV64I-NEXT: lbu zero, 0(a0)
36 ; RV64I-NEXT: lui a0, 24
37 ; RV64I-NEXT: addiw a0, a0, 1712
38 ; RV64I-NEXT: add sp, sp, a0
41 %va = alloca i8, align 4
42 %va1 = alloca i8, align 4
43 %large = alloca [ 100000 x i8 ]
44 %argp.cur = load volatile i8, ptr %va, align 4
45 %argp.next = load volatile i8, ptr %va1, align 4
49 ; Test containing a load with its own local offset. Make sure isFrameOffsetLegal
50 ; considers it and does not create a virtual base register.
51 define void @load_with_offset() {
52 ; RV32I-LABEL: load_with_offset:
54 ; RV32I-NEXT: lui a0, 25
55 ; RV32I-NEXT: addi a0, a0, -1792
56 ; RV32I-NEXT: sub sp, sp, a0
57 ; RV32I-NEXT: .cfi_def_cfa_offset 100608
58 ; RV32I-NEXT: lui a0, 25
59 ; RV32I-NEXT: add a0, sp, a0
60 ; RV32I-NEXT: lbu zero, -292(a0)
61 ; RV32I-NEXT: lui a0, 24
62 ; RV32I-NEXT: add a0, sp, a0
63 ; RV32I-NEXT: lbu zero, 1704(a0)
64 ; RV32I-NEXT: lui a0, 25
65 ; RV32I-NEXT: addi a0, a0, -1792
66 ; RV32I-NEXT: add sp, sp, a0
69 ; RV64I-LABEL: load_with_offset:
71 ; RV64I-NEXT: lui a0, 25
72 ; RV64I-NEXT: addiw a0, a0, -1792
73 ; RV64I-NEXT: sub sp, sp, a0
74 ; RV64I-NEXT: .cfi_def_cfa_offset 100608
75 ; RV64I-NEXT: lui a0, 25
76 ; RV64I-NEXT: add a0, sp, a0
77 ; RV64I-NEXT: lbu zero, -292(a0)
78 ; RV64I-NEXT: lui a0, 24
79 ; RV64I-NEXT: add a0, sp, a0
80 ; RV64I-NEXT: lbu zero, 1704(a0)
81 ; RV64I-NEXT: lui a0, 25
82 ; RV64I-NEXT: addiw a0, a0, -1792
83 ; RV64I-NEXT: add sp, sp, a0
86 %va = alloca [100 x i8], align 4
87 %va1 = alloca [500 x i8], align 4
88 %large = alloca [100000 x i8]
89 %va_gep = getelementptr [100 x i8], ptr %va, i64 16
90 %va1_gep = getelementptr [100 x i8], ptr %va1, i64 0
91 %load = load volatile i8, ptr %va_gep, align 4
92 %load1 = load volatile i8, ptr %va1_gep, align 4