https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119828
Bug ID: 119828 Summary: RISC-V gcc rv64gc fails to optimize away stack frame Product: gcc Version: 14.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: konstantin.vladimirov at gmail dot com Target Milestone: --- Source code: struct S { int a[4]; }; int foo(struct S s) { return s.a[3]; } Generated assembly: foo: addi sp,sp,-16 # useless srai a0,a1,32 addi sp,sp,16 # useless jr ra Clang is doing well in this case. https://godbolt.org/z/5PEP3z77K