1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=loongarch64 < %s | FileCheck %s
4 %struct.key_t = type { i32, [16 x i8] }
6 declare void @llvm.memset.p0i8.i64(ptr, i8, i64, i1)
7 declare void @test1(ptr)
9 define i32 @test() nounwind {
12 ; CHECK-NEXT: addi.d $sp, $sp, -32
13 ; CHECK-NEXT: st.d $ra, $sp, 24 # 8-byte Folded Spill
14 ; CHECK-NEXT: st.w $zero, $sp, 16
15 ; CHECK-NEXT: st.d $zero, $sp, 8
16 ; CHECK-NEXT: st.d $zero, $sp, 0
17 ; CHECK-NEXT: addi.d $a0, $sp, 4
18 ; CHECK-NEXT: bl %plt(test1)
19 ; CHECK-NEXT: move $a0, $zero
20 ; CHECK-NEXT: ld.d $ra, $sp, 24 # 8-byte Folded Reload
21 ; CHECK-NEXT: addi.d $sp, $sp, 32
23 %key = alloca %struct.key_t, align 4
24 call void @llvm.memset.p0i8.i64(ptr %key, i8 0, i64 20, i1 false)
25 %1 = getelementptr inbounds %struct.key_t, ptr %key, i64 0, i32 1, i64 0
26 call void @test1(ptr %1)
30 ;; Note: will create an emergency spill slot, if (!isInt<11>(StackSize)).
31 ;; Should involve only one SP-adjusting addi per adjustment.
32 define void @test_large_frame_size_2032() {
33 ; CHECK-LABEL: test_large_frame_size_2032:
35 ; CHECK-NEXT: addi.d $sp, $sp, -2032
36 ; CHECK-NEXT: .cfi_def_cfa_offset 2032
37 ; CHECK-NEXT: addi.d $sp, $sp, 2032
39 %1 = alloca i8, i32 2016 ; + 16(emergency slot) = 2032
43 ;; Should involve two SP-adjusting addi's when adjusting SP up, but only one
44 ;; when adjusting down.
45 define void @test_large_frame_size_2048() {
46 ; CHECK-LABEL: test_large_frame_size_2048:
48 ; CHECK-NEXT: addi.d $sp, $sp, -2048
49 ; CHECK-NEXT: .cfi_def_cfa_offset 2048
50 ; CHECK-NEXT: addi.d $sp, $sp, 2032
51 ; CHECK-NEXT: addi.d $sp, $sp, 16
53 %1 = alloca i8, i32 2032 ; + 16(emergency slot) = 2048
57 ;; Should involve two SP-adjusting addi's per adjustment.
58 define void @test_large_frame_size_2064() {
59 ; CHECK-LABEL: test_large_frame_size_2064:
61 ; CHECK-NEXT: addi.d $sp, $sp, -2048
62 ; CHECK-NEXT: addi.d $sp, $sp, -16
63 ; CHECK-NEXT: .cfi_def_cfa_offset 2064
64 ; CHECK-NEXT: addi.d $sp, $sp, 2032
65 ; CHECK-NEXT: addi.d $sp, $sp, 32
67 %1 = alloca i8, i32 2048 ; + 16(emergency slot) = 2064
71 ;; NOTE: Due to the problem with the emegency spill slot, the scratch register
72 ;; will not be used when the fp is eliminated. To make this test valid, add the
73 ;; attribute "frame-pointer=all".
75 ;; SP should be adjusted with help of a scratch register.
76 define void @test_large_frame_size_1234576() "frame-pointer"="all" {
77 ; CHECK-LABEL: test_large_frame_size_1234576:
79 ; CHECK-NEXT: addi.d $sp, $sp, -2032
80 ; CHECK-NEXT: .cfi_def_cfa_offset 2032
81 ; CHECK-NEXT: st.d $ra, $sp, 2024 # 8-byte Folded Spill
82 ; CHECK-NEXT: st.d $fp, $sp, 2016 # 8-byte Folded Spill
83 ; CHECK-NEXT: .cfi_offset 1, -8
84 ; CHECK-NEXT: .cfi_offset 22, -16
85 ; CHECK-NEXT: addi.d $fp, $sp, 2032
86 ; CHECK-NEXT: .cfi_def_cfa 22, 0
87 ; CHECK-NEXT: lu12i.w $a0, 300
88 ; CHECK-NEXT: ori $a0, $a0, 3760
89 ; CHECK-NEXT: sub.d $sp, $sp, $a0
90 ; CHECK-NEXT: lu12i.w $a0, 300
91 ; CHECK-NEXT: ori $a0, $a0, 3760
92 ; CHECK-NEXT: add.d $sp, $sp, $a0
93 ; CHECK-NEXT: ld.d $fp, $sp, 2016 # 8-byte Folded Reload
94 ; CHECK-NEXT: ld.d $ra, $sp, 2024 # 8-byte Folded Reload
95 ; CHECK-NEXT: addi.d $sp, $sp, 2032
97 %1 = alloca i8, i32 1234567