https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64907
Bug ID: 64907 Summary: Suboptimal code (saving rbx on stack in order to save another reg in rbx) Product: gcc Version: 4.7.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: vda.linux at googlemail dot com void put_16bit(unsigned short v); void put_32bit(unsigned v) { put_16bit(v); put_16bit(v >> 16); } With gcc 4.7.2 the above compiles to the following assembly: put_32bit: pushq %rbx movl %edi, %ebx andl $65535, %edi call put_16bit movl %ebx, %edi popq %rbx shrl $16, %edi jmp put_16bit Code saves %rbx on stack only in order to save %edi to %ebx. A simpler alternative is to just save %rdi on stack: put_32bit: pushq %rdi andl $65535, %edi call put_16bit popq %rdi shrl $16, %edi jmp put_16bit