public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/19464] New: [3.3/3.4/4.0 Regression] gcse causes poor register allocation
@ 2005-01-15 20:58 belyshev at depni dot sinp dot msu dot ru
2005-01-15 20:59 ` [Bug rtl-optimization/19464] " belyshev at depni dot sinp dot msu dot ru
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: belyshev at depni dot sinp dot msu dot ru @ 2005-01-15 20:58 UTC (permalink / raw)
To: gcc-bugs
GCC with gcse enabled generates very poor code for this fragment:
------------------------------------------------------------------------------
int r0, r1, r2, r3, r4, r5;
void f (int n)
{
while (-- n)
{
r1 += r0;
r2 += r1;
r3 += r2;
r4 += r3;
r5 += r4;
r0 += r5;
}
}
------------------------------------------------------------------------------
This is code from 3.4.4 with -O2 -fomit-frame-pointer:
.L4:
movl 16(%esp), %ebp
movl 12(%esp), %esi
movl 8(%esp), %ecx
movl 4(%esp), %edx
movl (%esp), %eax
addl %edi, %ebp
addl %ebp, %esi
movl %ebp, 16(%esp)
addl %esi, %ecx
movl %esi, 12(%esp)
addl %ecx, %edx
movl %ecx, 8(%esp)
addl %edx, %eax
decl 20(%esp)
movl %edx, 4(%esp)
leal (%edi,%eax), %ebx
movl %eax, (%esp)
movl %ebx, %edi
jne .L4
And this is with -O2 -fomit-frame-pointer -fno-gcse:
.L4:
addl %edi, %ebp
addl %ebp, %ebx
addl %ebx, %ecx
addl %ecx, %edx
addl %edx, %eax
addl %eax, %edi
decl %esi
jne .L4
Same applies for 4.0.0, only one should use '-O2 -fomit-frame-pointer
-fno-tree-loop-im -fno-gcse' to get decent code.
This is a regression and was introduced by this change:
2001-07-16 Daniel Berlin <dan@cgsoftware.com>
* gcse.c: Update comment at top.
Update comment on mem handling.
mem_last_set, mem_first_set, mem_set_in_block: gone.
Declaration of reg_set_info: gone.
(oprs_unchanged_p): Don't use mem_*set_* anymore. They are
pointless with load_killed_in_block_p (they are *more*
conservative then it, not less, and less accurate).
(oprs_not_set_p): Ditto.
(alloc_gcse_mem): Don't allocate mem_set_in_block
(free_gcse_mem): Don't free it, either.
(record_last_mem_set_info): Update comment in front, remove
mem_*set_* stuff. Note the reason we don't handle stores directly
here.
(compute_hash_table): Update comments to reflect reality. Remove
mem_*set_* references.
(reset_opr_set_tables): Remove mem_*set_* references.
(mark_call): Ditto.
(mark_set): Ditto. Also remove double sets of bitmaps for REG's.
(mark_clobber): Ditto (on both parts, we double set here too).
(expr_killed_p): Remove mem_set_in_block test.
(compute_transp): Remove mem_set_in_block test.
--
Summary: [3.3/3.4/4.0 Regression] gcse causes poor register
allocation
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P2
Component: rtl-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: belyshev at depni dot sinp dot msu dot ru
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19464
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/19464] [3.3/3.4/4.0 Regression] gcse causes poor register allocation
2005-01-15 20:58 [Bug rtl-optimization/19464] New: [3.3/3.4/4.0 Regression] gcse causes poor register allocation belyshev at depni dot sinp dot msu dot ru
@ 2005-01-15 20:59 ` belyshev at depni dot sinp dot msu dot ru
2005-01-15 21:04 ` pinskia at gcc dot gnu dot org
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: belyshev at depni dot sinp dot msu dot ru @ 2005-01-15 20:59 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Known to fail| |3.3.5 3.4.4 4.0.0
Known to work| |2.95.3 3.0.4
Target Milestone|--- |4.0.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19464
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/19464] [3.3/3.4/4.0 Regression] gcse causes poor register allocation
2005-01-15 20:58 [Bug rtl-optimization/19464] New: [3.3/3.4/4.0 Regression] gcse causes poor register allocation belyshev at depni dot sinp dot msu dot ru
2005-01-15 20:59 ` [Bug rtl-optimization/19464] " belyshev at depni dot sinp dot msu dot ru
@ 2005-01-15 21:04 ` pinskia at gcc dot gnu dot org
2005-01-15 21:44 ` dberlin at dberlin dot org
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-15 21:04 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-01-15 21:04 -------
Confirmed, for 3.4 and 3.3, -fnew-ra fixes the problem so this is just the register allocator really being
stupid.
With 4.0 and -fnew-ra, we just seg fault (I think this is why we should remove -fnew-ra on the mainline
because it does not work on most programs at all).
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2005-01-15 21:04:44
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19464
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/19464] [3.3/3.4/4.0 Regression] gcse causes poor register allocation
2005-01-15 20:58 [Bug rtl-optimization/19464] New: [3.3/3.4/4.0 Regression] gcse causes poor register allocation belyshev at depni dot sinp dot msu dot ru
2005-01-15 20:59 ` [Bug rtl-optimization/19464] " belyshev at depni dot sinp dot msu dot ru
2005-01-15 21:04 ` pinskia at gcc dot gnu dot org
@ 2005-01-15 21:44 ` dberlin at dberlin dot org
2005-01-15 21:48 ` dberlin at dberlin dot org
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: dberlin at dberlin dot org @ 2005-01-15 21:44 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From dberlin at gcc dot gnu dot org 2005-01-15 21:44 -------
Subject: Re: New: [3.3/3.4/4.0 Regression]
gcse causes poor register allocation
> This is a regression and was introduced by this change:
I have a very hard time believing this, since the patch below only
touched store motion.
>
> 2001-07-16 Daniel Berlin <dan@cgsoftware.com>
>
> * gcse.c: Update comment at top.
> Update comment on mem handling.
> mem_last_set, mem_first_set, mem_set_in_block: gone.
> Declaration of reg_set_info: gone.
> (oprs_unchanged_p): Don't use mem_*set_* anymore. They are
> pointless with load_killed_in_block_p (they are *more*
> conservative then it, not less, and less accurate).
> (oprs_not_set_p): Ditto.
> (alloc_gcse_mem): Don't allocate mem_set_in_block
> (free_gcse_mem): Don't free it, either.
> (record_last_mem_set_info): Update comment in front, remove
> mem_*set_* stuff. Note the reason we don't handle stores directly
> here.
> (compute_hash_table): Update comments to reflect reality. Remove
> mem_*set_* references.
> (reset_opr_set_tables): Remove mem_*set_* references.
> (mark_call): Ditto.
> (mark_set): Ditto. Also remove double sets of bitmaps for REG's.
> (mark_clobber): Ditto (on both parts, we double set here too).
> (expr_killed_p): Remove mem_set_in_block test.
> (compute_transp): Remove mem_set_in_block test.
>
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19464
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/19464] [3.3/3.4/4.0 Regression] gcse causes poor register allocation
2005-01-15 20:58 [Bug rtl-optimization/19464] New: [3.3/3.4/4.0 Regression] gcse causes poor register allocation belyshev at depni dot sinp dot msu dot ru
` (2 preceding siblings ...)
2005-01-15 21:44 ` dberlin at dberlin dot org
@ 2005-01-15 21:48 ` dberlin at dberlin dot org
2005-01-21 12:25 ` steven at gcc dot gnu dot org
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: dberlin at dberlin dot org @ 2005-01-15 21:48 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From dberlin at gcc dot gnu dot org 2005-01-15 21:48 -------
Subject: Re: [3.3/3.4/4.0 Regression] gcse
causes poor register allocation
On Sat, 2005-01-15 at 21:44 +0000, dberlin at dberlin dot org wrote:
> ------- Additional Comments From dberlin at gcc dot gnu dot org 2005-01-15 21:44 -------
> Subject: Re: New: [3.3/3.4/4.0 Regression]
> gcse causes poor register allocation
>
>
> > This is a regression and was introduced by this change:
>
> I have a very hard time believing this, since the patch below only
> touched store motion.
Unless, of course, GCSE was completely broken for simple expressions
somehow before the patch.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19464
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/19464] [3.3/3.4/4.0 Regression] gcse causes poor register allocation
2005-01-15 20:58 [Bug rtl-optimization/19464] New: [3.3/3.4/4.0 Regression] gcse causes poor register allocation belyshev at depni dot sinp dot msu dot ru
` (3 preceding siblings ...)
2005-01-15 21:48 ` dberlin at dberlin dot org
@ 2005-01-21 12:25 ` steven at gcc dot gnu dot org
2005-01-21 12:51 ` steven at gcc dot gnu dot org
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: steven at gcc dot gnu dot org @ 2005-01-21 12:25 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From steven at gcc dot gnu dot org 2005-01-21 12:25 -------
This can be fixed at the tree level without any gcse or ra hacking:
http://gcc.gnu.org/ml/gcc-patches/2005-01/msg01462.html
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |steven at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
Last reconfirmed|2005-01-15 21:04:44 |2005-01-21 12:25:01
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19464
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/19464] [3.3/3.4/4.0 Regression] gcse causes poor register allocation
2005-01-15 20:58 [Bug rtl-optimization/19464] New: [3.3/3.4/4.0 Regression] gcse causes poor register allocation belyshev at depni dot sinp dot msu dot ru
` (4 preceding siblings ...)
2005-01-21 12:25 ` steven at gcc dot gnu dot org
@ 2005-01-21 12:51 ` steven at gcc dot gnu dot org
2005-01-23 0:42 ` belyshev at depni dot sinp dot msu dot ru
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: steven at gcc dot gnu dot org @ 2005-01-21 12:51 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From steven at gcc dot gnu dot org 2005-01-21 12:51 -------
With my patch I get almost perfect code for amd64:
.globl f
.type f, @function
f:
.LFB2:
decl %edi
je .L6
movl r5(%rip), %r9d
movl r4(%rip), %r8d
xorl %r10d, %r10d
movl r3(%rip), %esi
movl r2(%rip), %ecx
movl r0(%rip), %edx
movl r1(%rip), %eax
.p2align 4,,7
.L4:
addl %edx, %eax
incl %r10d
addl %eax, %ecx
addl %ecx, %esi
addl %esi, %r8d
addl %r8d, %r9d
addl %r9d, %edx
cmpl %r10d, %edi
jne .L4
movl %r9d, r5(%rip)
movl %r8d, r4(%rip)
movl %esi, r3(%rip)
movl %ecx, r2(%rip)
movl %edx, r0(%rip)
movl %eax, r1(%rip)
.L6:
rep ; ret
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19464
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/19464] [3.3/3.4/4.0 Regression] gcse causes poor register allocation
2005-01-15 20:58 [Bug rtl-optimization/19464] New: [3.3/3.4/4.0 Regression] gcse causes poor register allocation belyshev at depni dot sinp dot msu dot ru
` (5 preceding siblings ...)
2005-01-21 12:51 ` steven at gcc dot gnu dot org
@ 2005-01-23 0:42 ` belyshev at depni dot sinp dot msu dot ru
2005-01-23 1:17 ` pinskia at gcc dot gnu dot org
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: belyshev at depni dot sinp dot msu dot ru @ 2005-01-23 0:42 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From belyshev at depni dot sinp dot msu dot ru 2005-01-23 00:42 -------
(In reply to comment #4)
> This can be fixed at the tree level without any gcse or ra hacking:
> http://gcc.gnu.org/ml/gcc-patches/2005-01/msg01462.html
GCC generates poor code for this function even with that patch applied:
int r[6];
void g (int n)
{
while (-- n)
{
r [0] += r [5];
r [1] += r [0];
r [2] += r [1];
r [3] += r [2];
r [4] += r [3];
r [5] += r [4];
}
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19464
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/19464] [3.3/3.4/4.0 Regression] gcse causes poor register allocation
2005-01-15 20:58 [Bug rtl-optimization/19464] New: [3.3/3.4/4.0 Regression] gcse causes poor register allocation belyshev at depni dot sinp dot msu dot ru
` (6 preceding siblings ...)
2005-01-23 0:42 ` belyshev at depni dot sinp dot msu dot ru
@ 2005-01-23 1:17 ` pinskia at gcc dot gnu dot org
2005-01-23 1:43 ` belyshev at depni dot sinp dot msu dot ru
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-23 1:17 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-01-23 01:17 -------
(In reply to comment #6)
> (In reply to comment #4)
> > This can be fixed at the tree level without any gcse or ra hacking:
> > http://gcc.gnu.org/ml/gcc-patches/2005-01/msg01462.html
>
> GCC generates poor code for this function even with that patch applied:
This looks like a different bug because with 3.3.3 we get the good code but not with 3.4.0.
Good code meaning:
.L5:
addl %edi, %ebp
addl %ebp, %esi
addl %esi, %ecx
addl %ecx, %edx
addl %edx, %eax
addl %eax, %edi
decl %ebx
jne .L5
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19464
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/19464] [3.3/3.4/4.0 Regression] gcse causes poor register allocation
2005-01-15 20:58 [Bug rtl-optimization/19464] New: [3.3/3.4/4.0 Regression] gcse causes poor register allocation belyshev at depni dot sinp dot msu dot ru
` (7 preceding siblings ...)
2005-01-23 1:17 ` pinskia at gcc dot gnu dot org
@ 2005-01-23 1:43 ` belyshev at depni dot sinp dot msu dot ru
2005-01-23 19:36 ` cvs-commit at gcc dot gnu dot org
2005-01-23 19:43 ` steven at gcc dot gnu dot org
10 siblings, 0 replies; 12+ messages in thread
From: belyshev at depni dot sinp dot msu dot ru @ 2005-01-23 1:43 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From belyshev at depni dot sinp dot msu dot ru 2005-01-23 01:43 -------
(In reply to comment #7)
> This looks like a different bug because with 3.3.3 we get the good code but
not with 3.4.0.
this is now bug 19580
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19464
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/19464] [3.3/3.4/4.0 Regression] gcse causes poor register allocation
2005-01-15 20:58 [Bug rtl-optimization/19464] New: [3.3/3.4/4.0 Regression] gcse causes poor register allocation belyshev at depni dot sinp dot msu dot ru
` (8 preceding siblings ...)
2005-01-23 1:43 ` belyshev at depni dot sinp dot msu dot ru
@ 2005-01-23 19:36 ` cvs-commit at gcc dot gnu dot org
2005-01-23 19:43 ` steven at gcc dot gnu dot org
10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-01-23 19:36 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2005-01-23 19:36 -------
Subject: Bug 19464
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: steven@gcc.gnu.org 2005-01-23 19:36:01
Modified files:
gcc : ChangeLog tree-optimize.c
Log message:
PR rtl-optimization/19464
* tree-optimize.c (init_tree_optimization_passes): Add one more
copyrename pass just before out-of-ssa.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.7249&r2=2.7250
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-optimize.c.diff?cvsroot=gcc&r1=2.69&r2=2.70
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19464
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/19464] [3.3/3.4/4.0 Regression] gcse causes poor register allocation
2005-01-15 20:58 [Bug rtl-optimization/19464] New: [3.3/3.4/4.0 Regression] gcse causes poor register allocation belyshev at depni dot sinp dot msu dot ru
` (9 preceding siblings ...)
2005-01-23 19:36 ` cvs-commit at gcc dot gnu dot org
@ 2005-01-23 19:43 ` steven at gcc dot gnu dot org
10 siblings, 0 replies; 12+ messages in thread
From: steven at gcc dot gnu dot org @ 2005-01-23 19:43 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From steven at gcc dot gnu dot org 2005-01-23 19:43 -------
.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19464
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2005-01-23 19:43 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-15 20:58 [Bug rtl-optimization/19464] New: [3.3/3.4/4.0 Regression] gcse causes poor register allocation belyshev at depni dot sinp dot msu dot ru
2005-01-15 20:59 ` [Bug rtl-optimization/19464] " belyshev at depni dot sinp dot msu dot ru
2005-01-15 21:04 ` pinskia at gcc dot gnu dot org
2005-01-15 21:44 ` dberlin at dberlin dot org
2005-01-15 21:48 ` dberlin at dberlin dot org
2005-01-21 12:25 ` steven at gcc dot gnu dot org
2005-01-21 12:51 ` steven at gcc dot gnu dot org
2005-01-23 0:42 ` belyshev at depni dot sinp dot msu dot ru
2005-01-23 1:17 ` pinskia at gcc dot gnu dot org
2005-01-23 1:43 ` belyshev at depni dot sinp dot msu dot ru
2005-01-23 19:36 ` cvs-commit at gcc dot gnu dot org
2005-01-23 19:43 ` steven at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).