https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103648
Bug ID: 103648 Summary: Missed optimization on arm64 when returning an empty struct. Product: gcc Version: 11.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: boleyn.su at gmail dot com Target Milestone: --- In the following C code, gcc generates different assembly for `f` and `g` ```c struct Void {}; struct Void f(int x) { return (struct Void) {}; } void g(int x) {} ``` I believe it can be optimized somehow and clang does optimize them to be identical. gcc trunk vs clang trunk on ARM 64-bit https://godbolt.org/z/W8ocj6vsK Jonathan Wakely finds something that may be related. https://reviews.llvm.org/D89490 which references https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms#Pass-Arguments-to-Functions-Correctly