https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92549
Bug ID: 92549 Summary: Use x86 xchg instruction more Product: gcc Version: 9.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: drepper.fsp+rhbz at gmail dot com Target Milestone: --- Take this code __attribute__((noinline)) int f(int a, int b) { return b - a + 5; } int foo(int a, int b) { return 1 + f(b, a); } int main() { return foo(39, 3); } gcc 9.2.1 generates for foo on x86-64 this code: movl %edi, %r8d movl %esi, %edi movl %r8d, %esi call f addl $1, %eax ret This could be better: xchgl %edi, %esi call f addl $1, %eax ret Switching parameter location is not a uncommon pattern. If the regparm is used on x86-32 the same likely applies there.