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