https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110188
--- Comment #2 from 18761437418 at 163 dot com --- thank you very much, I have tried different optimization levels, but all occupy 32bytes. O0, O1, O2, O3, Os all occupy 32bytes. comand: riscv64-unknown-elf-gcc -c main.c -o main.o -march=rv32imac -mpreferred-stack-boundary=4 -O3 O3 assembly code is following, it only use 2 words as stack, but still occupy 32bytes. 00000000 <main>: 0: 1101 addi sp,sp,-32 2: 47a5 li a5,9 4: c03e sw a5,0(sp) 6: 48a1 li a7,8 8: 481d li a6,7 a: 4799 li a5,6 c: 4715 li a4,5 e: 4691 li a3,4 10: 460d li a2,3 12: 4589 li a1,2 14: 4505 li a0,1 16: ce06 sw ra,28(sp) 18: 00000097 auipc ra,0x0 1c: 000080e7 jalr ra # 18 <main+0x18> 20: 40f2 lw ra,28(sp) 22: 6105 addi sp,sp,32 24: 8082 ret At 2023-06-09 15:56:48, "pinskia at gcc dot gnu.org" <gcc-bugzi...@gcc.gnu.org> wrote: >https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110188 > >--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- >This is at -O0. Maybe -O1 or -O2 will use the reduced stack size. > >-- >You are receiving this mail because: >You reported the bug.