xref: /llvm-project/llvm/test/CodeGen/RISCV/split-sp-adjust.ll (revision eabaee0c59110d0e11b33a69db54ccda526b35fd)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \
3; RUN:   | FileCheck %s -check-prefix=RV32I
4
5; The stack size is 2048 and the SP adjustment will be split.
6define i32 @SplitSP() nounwind {
7; RV32I-LABEL: SplitSP:
8; RV32I:       # %bb.0: # %entry
9; RV32I-NEXT:    addi sp, sp, -2032
10; RV32I-NEXT:    sw ra, 2028(sp) # 4-byte Folded Spill
11; RV32I-NEXT:    addi sp, sp, -16
12; RV32I-NEXT:    addi a0, sp, 16
13; RV32I-NEXT:    call foo
14; RV32I-NEXT:    li a0, 0
15; RV32I-NEXT:    addi sp, sp, 16
16; RV32I-NEXT:    lw ra, 2028(sp) # 4-byte Folded Reload
17; RV32I-NEXT:    addi sp, sp, 2032
18; RV32I-NEXT:    ret
19entry:
20  %xx = alloca [2028 x i8], align 1
21  %call = call i32 @foo(ptr nonnull %xx)
22  ret i32 0
23}
24
25; The stack size is 2032 and the SP adjustment will not be split.
26define i32 @NoSplitSP() nounwind {
27; RV32I-LABEL: NoSplitSP:
28; RV32I:       # %bb.0: # %entry
29; RV32I-NEXT:    addi sp, sp, -2032
30; RV32I-NEXT:    sw ra, 2028(sp) # 4-byte Folded Spill
31; RV32I-NEXT:    addi a0, sp, 4
32; RV32I-NEXT:    call foo
33; RV32I-NEXT:    li a0, 0
34; RV32I-NEXT:    lw ra, 2028(sp) # 4-byte Folded Reload
35; RV32I-NEXT:    addi sp, sp, 2032
36; RV32I-NEXT:    ret
37entry:
38  %xx = alloca [2024 x i8], align 1
39  %call = call i32 @foo(ptr nonnull %xx)
40  ret i32 0
41}
42
43declare i32 @foo(ptr)
44