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)
11; RV32I-NEXT:    addi sp, sp, -16
12; RV32I-NEXT:    addi a0, sp, 16
13; RV32I-NEXT:    call foo
14; RV32I-NEXT:    mv a0, zero
15; RV32I-NEXT:    addi sp, sp, 16
16; RV32I-NEXT:    lw ra, 2028(sp)
17; RV32I-NEXT:    addi sp, sp, 2032
18; RV32I-NEXT:    ret
19entry:
20  %xx = alloca [2028 x i8], align 1
21  %0 = getelementptr inbounds [2028 x i8], [2028 x i8]* %xx, i32 0, i32 0
22  %call = call i32 @foo(i8* nonnull %0)
23  ret i32 0
24}
25
26; The stack size is 2032 and the SP adjustment will not be split.
27define i32 @NoSplitSP() nounwind {
28; RV32I-LABEL: NoSplitSP:
29; RV32I:       # %bb.0: # %entry
30; RV32I-NEXT:    addi sp, sp, -2032
31; RV32I-NEXT:    sw ra, 2028(sp)
32; RV32I-NEXT:    addi a0, sp, 4
33; RV32I-NEXT:    call foo
34; RV32I-NEXT:    mv a0, zero
35; RV32I-NEXT:    lw ra, 2028(sp)
36; RV32I-NEXT:    addi sp, sp, 2032
37; RV32I-NEXT:    ret
38entry:
39  %xx = alloca [2024 x i8], align 1
40  %0 = getelementptr inbounds [2024 x i8], [2024 x i8]* %xx, i32 0, i32 0
41  %call = call i32 @foo(i8* nonnull %0)
42  ret i32 0
43}
44
45declare i32 @foo(i8*)
46