Bug 23812 - swapping DImode halves produces poor x86 register allocation
Summary: swapping DImode halves produces poor x86 register allocation
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: unknown
: P2 enhancement
Target Milestone: 4.3.0
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization, ra
: 27202 (view as bug list)
Depends on: 15792 18427
Blocks: 23813
  Show dependency treegraph
 
Reported: 2005-09-11 02:00 UTC by Ken Raeburn
Modified: 2007-02-02 01:13 UTC (History)
4 users (show)

See Also:
Host:
Target: i686-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-10-22 22:19:12


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ken Raeburn 2005-09-11 02:00:56 UTC
(CVS sources, ~6AM this morning US/eastern)

typedef unsigned long long uint64_t;
uint64_t foo (uint64_t n) {
  return (n >> 32) | (n << 32);
}

compiled with -O9 -fomit-frame-pointer:

foo:
        pushl   %ebx
        movl    12(%esp), %ebx
        movl    8(%esp), %ecx
        movl    %ebx, %eax
        popl    %ebx
        movl    %ecx, %edx
        ret

It should've been able to load 4(%esp) and 8(%esp) into %edx and %eax respectively, without using the 
extra stack slot to save ebx.
Comment 1 Andrew Pinski 2005-09-11 14:22:32 UTC
This is the normal subreg problem with the current RA.  There are a couple other bugs about this 
already opened.
Comment 2 Andrew Pinski 2005-09-12 14:31:13 UTC
Confirmed, basicially the same issue as PR 15792.
Comment 3 Michael Meissner 2005-10-18 17:44:23 UTC
Note, since this is a rotate, the patches I proposed in 17886 will generate much better code for this one case (basically mov/mov/xchgl -- it could be improved by a peephole to do the moves directly instead of xchgl).  However, the more general subreg problem needs to be looked at.
Comment 4 Ian Lance Taylor 2006-02-07 08:31:46 UTC
With my current set of subreg patches, for this test case with -O2 -momit-leaf-frame-pointer, I get this:

foo:
	movl	4(%esp), %edx
	movl	8(%esp), %eax
	ret

which I suspect is optimal.
Comment 5 Andrew Pinski 2006-04-19 02:50:11 UTC
*** Bug 27202 has been marked as a duplicate of this bug. ***
Comment 6 Andrew Pinski 2007-02-02 01:13:47 UTC
Fixed by:
2007-01-31  Richard Henderson  <rth@redhat.com>
            Ian Lance Taylor  <iant@google.com>

        * lower-subreg.c: New file.