https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103010
Bug ID: 103010 Summary: Extra move to x0 for non-POD returns Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Take the following C++ code: void ll() noexcept(true); struct k { ~k() noexcept(true); }; k ice(k *a) { k v; ll(); return v; } ---- CUT ---- Currently GCC produces: stp x29, x30, [sp, -32]! mov x29, sp str x19, [sp, 16] mov x19, x8 bl _Z2llv mov x0, x19 ldr x19, [sp, 16] ldp x29, x30, [sp], 32 But the ABI does say x0 need to be set here at all. So really the call to _Z2llv could even be a tail call.