https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95941
Bug ID: 95941 Summary: Passing a struct by value wastes 16 bytes on the stack Product: gcc Version: 10.1.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: josephcsible at gmail dot com Target Milestone: --- Target: x86_64-linux-gnu Consider this C code: extern struct foo { long x, y, z; } s; void f(struct foo); void g(void) { f(s); } At "-O3", it compiles to this: g: subq $16, %rsp pushq s+16(%rip) pushq s+8(%rip) pushq s(%rip) call f addq $40, %rsp ret There's no reason at all to use that extra 16 bytes of stack space. It should have compiled to this instead: g: pushq s+16(%rip) pushq s+8(%rip) pushq s(%rip) call f addq $24, %rsp ret