Bug 99531 - [11 Regression] Performance regression since gcc 9 (argument passing / register allocation)
Summary: [11 Regression] Performance regression since gcc 9 (argument passing / regist...
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 10.2.0
: P2 normal
Target Milestone: 11.5
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization, ra
Depends on:
Blocks:
 
Reported: 2021-03-10 22:36 UTC by Stefan Ring
Modified: 2023-07-07 10:39 UTC (History)
4 users (show)

See Also:
Host:
Target: x86_64
Build:
Known to work: 8.4.0
Known to fail: 11.0, 9.3.1
Last reconfirmed: 2021-03-11 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Ring 2021-03-10 22:36:26 UTC
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
Comment 1 Richard Biener 2021-03-11 08:32:48 UTC
Confirmed.
Comment 2 Martin Liška 2021-03-11 09:35:27 UTC
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
Comment 3 Richard Biener 2021-06-01 08:19:55 UTC
GCC 9.4 is being released, retargeting bugs to GCC 9.5.
Comment 4 Vladimir Makarov 2021-12-07 13:48:41 UTC
  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.
Comment 5 GCC Commits 2021-12-13 19:11:14 UTC
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.
Comment 6 GCC Commits 2021-12-14 15:04:35 UTC
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.
Comment 7 Richard Biener 2022-05-27 09:44:43 UTC
GCC 9 branch is being closed
Comment 8 Jakub Jelinek 2022-06-28 10:43:56 UTC
GCC 10.4 is being released, retargeting bugs to GCC 10.5.
Comment 9 Roger Sayle 2023-01-12 23:36:36 UTC
This has been fixed for GCC 12 and GCC 13.  Thanks to Vladimir.
Comment 10 Richard Biener 2023-07-07 10:39:14 UTC
GCC 10 branch is being closed.