For this source: int func(int, int, int, int, int, int); int caller(int a, int b, int c, int d, int e) { return func(0, a, b, c, d, e); } the code generated for caller is: pushq %r12 movl %r8d, %r9d popq %r12 movl %ecx, %r8d movl %edx, %ecx movl %esi, %edx movl %edi, %esi xorl %edi, %edi jmp func gcc 9 started producing the useless push/pop pair. Mailing list link: https://gcc.gnu.org/pipermail/gcc-help/2021-February/139885.html
Confirmed.
Started with r9-4310-geeae9314d4449b76: caller: .LFB0: .cfi_startproc pushq %r12 .cfi_def_cfa_offset 16 .cfi_offset 12, -16 movl %r8d, %r9d popq %r12 .cfi_def_cfa_offset 8 movl %ecx, %r8d movl %edx, %ecx movl %esi, %edx movl %edi, %esi xorl %edi, %edi jmp func .cfi_endproc before the revision: caller: .LFB0: .cfi_startproc movl %r8d, %r9d movl %ecx, %r8d movl %edx, %ecx movl %esi, %edx movl %edi, %esi xorl %edi, %edi jmp func .cfi_endproc
GCC 9.4 is being released, retargeting bugs to GCC 9.5.
Thank you for reporting this. It is true my patch caused this. I've reproduced the bug on master too. I will be working on this PR. I think a fix will be ready on the next week the best as the fix will touch cost calculations and will require a lot of testing on different targets.
The master branch has been updated by Vladimir Makarov <vmakarov@gcc.gnu.org>: https://gcc.gnu.org/g:a7acb6dca941db2b1c135107dac3a34a20650d5c commit r12-5944-ga7acb6dca941db2b1c135107dac3a34a20650d5c Author: Vladimir N. Makarov <vmakarov@redhat.com> Date: Mon Dec 13 13:48:12 2021 -0500 [PR99531] Modify pseudo class cost calculation when processing move involving the pseudo and a hard register Pseudo class calculated on the 1st iteration should not have a special treatment in cost calculation when processing move involving the pseudo and a hard register. gcc/ChangeLog: PR target/99531 * ira-costs.c (record_operand_costs): Do not take pseudo class calculated on the 1st iteration into account when processing move involving the pseudo and a hard register. gcc/testsuite/ChangeLog: PR target/99531 * gcc.target/i386/pr99531.c: New test.
The master branch has been updated by Vladimir Makarov <vmakarov@gcc.gnu.org>: https://gcc.gnu.org/g:973f6aedeb6489a9fdc7aeceaed0514348ee1e1a commit r12-5957-g973f6aedeb6489a9fdc7aeceaed0514348ee1e1a Author: Vladimir N. Makarov <vmakarov@redhat.com> Date: Tue Dec 14 08:57:30 2021 -0500 [PR99531] Do not scan push insn for ia32 in the test The patch prohibits scanning push insn for ia32 as push are expected not to be generated only for x86_64 Linux ABI. gcc/testsuite/ChangeLog: PR target/99531 * gcc.target/i386/pr99531.c: Do not scan for ia32.
GCC 9 branch is being closed
GCC 10.4 is being released, retargeting bugs to GCC 10.5.
This has been fixed for GCC 12 and GCC 13. Thanks to Vladimir.
GCC 10 branch is being closed.