public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/49865] New: Unneccessary reload causes small size regression from 4.6.1
@ 2011-07-27 11:25 sgunderson at bigfoot dot com
2011-07-27 11:39 ` [Bug target/49865] Unnecessary " sgunderson at bigfoot dot com
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: sgunderson at bigfoot dot com @ 2011-07-27 11:25 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49865
Summary: Unneccessary reload causes small size regression from
4.6.1
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: sgunderson@bigfoot.com
Target: i?86-*-*
Comparing 4.6.1 with gcc-snapshot from Debian:
gcc version 4.7.0 20110709 (experimental) [trunk revision 176106] (Debian
20110709-1)
Given this code:
fugl:~> cat test.cpp
#include <string.h>
class MyClass {
void func();
float f[1024];
int i;
};
void MyClass::func()
{
memset(f, 0, sizeof(f));
i = 0;
}
and compiling with
fugl:~> /usr/lib/gcc-snapshot/bin/g++ -Os -c test.cpp
g++ produces, according to objdump:
00000000 <_ZN7MyClass4funcEv>:
0: 55 push %ebp
1: 31 c0 xor %eax,%eax
3: 89 e5 mov %esp,%ebp
5: b9 00 04 00 00 mov $0x400,%ecx
a: 57 push %edi
b: 8b 7d 08 mov 0x8(%ebp),%edi
e: f3 ab rep stos %eax,%es:(%edi)
10: 8b 45 08 mov 0x8(%ebp),%eax
13: c7 80 00 10 00 00 00 movl $0x0,0x1000(%eax)
1a: 00 00 00
1d: 5f pop %edi
1e: 5d pop %ebp
1f: c3 ret
while 4.6.1 has a more efficient sequence:
00000000 <_ZN7MyClass4funcEv>:
0: 55 push %ebp
1: b9 00 04 00 00 mov $0x400,%ecx
6: 89 e5 mov %esp,%ebp
8: 31 c0 xor %eax,%eax
a: 8b 55 08 mov 0x8(%ebp),%edx
d: 57 push %edi
e: 89 d7 mov %edx,%edi
10: f3 ab rep stos %eax,%es:(%edi)
12: c7 82 00 10 00 00 00 movl $0x0,0x1000(%edx)
19: 00 00 00
1c: 5f pop %edi
1d: 5d pop %ebp
1e: c3 ret
It seems 4.6 is able to take a copy of the "this" pointer from a register
before the "rep stos" operation, which is one byte smaller than reloading it
from the stack when it needs to clear "i".
Of course, the _most_ efficient code sequence here would be doing the i = 0
before the memset, but I'm not sure if this is legal. However, eax should still
contain zero, so the mov could be done from eax instead of from a constant.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/49865] Unnecessary reload causes small size regression from 4.6.1
2011-07-27 11:25 [Bug target/49865] New: Unneccessary reload causes small size regression from 4.6.1 sgunderson at bigfoot dot com
@ 2011-07-27 11:39 ` sgunderson at bigfoot dot com
2011-07-27 17:29 ` [Bug target/49865] [4.7 Regression] Unnecessary reload causes small bloat sgunderson at bigfoot dot com
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: sgunderson at bigfoot dot com @ 2011-07-27 11:39 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49865
--- Comment #1 from sgunderson at bigfoot dot com 2011-07-27 11:38:57 UTC ---
(In reply to comment #0)
> Of course, the _most_ efficient code sequence here would be doing the i = 0
> before the memset, but I'm not sure if this is legal. However, eax should still
> contain zero, so the mov could be done from eax instead of from a constant.
Actually, thinking about it, the most efficient code sequence would be just
giving 4100 to memset instead of 4096, but that's for an enhancement request at
some point.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/49865] [4.7 Regression] Unnecessary reload causes small bloat
2011-07-27 11:25 [Bug target/49865] New: Unneccessary reload causes small size regression from 4.6.1 sgunderson at bigfoot dot com
2011-07-27 11:39 ` [Bug target/49865] Unnecessary " sgunderson at bigfoot dot com
@ 2011-07-27 17:29 ` sgunderson at bigfoot dot com
2011-08-01 14:33 ` rguenth at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: sgunderson at bigfoot dot com @ 2011-07-27 17:29 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49865
--- Comment #2 from sgunderson at bigfoot dot com 2011-07-27 17:28:19 UTC ---
(In reply to comment #1)
> Actually, thinking about it, the most efficient code sequence would be just
> giving 4100 to memset instead of 4096, but that's for an enhancement request at
> some point.
Filed as bug #49872.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/49865] [4.7 Regression] Unnecessary reload causes small bloat
2011-07-27 11:25 [Bug target/49865] New: Unneccessary reload causes small size regression from 4.6.1 sgunderson at bigfoot dot com
2011-07-27 11:39 ` [Bug target/49865] Unnecessary " sgunderson at bigfoot dot com
2011-07-27 17:29 ` [Bug target/49865] [4.7 Regression] Unnecessary reload causes small bloat sgunderson at bigfoot dot com
@ 2011-08-01 14:33 ` rguenth at gcc dot gnu.org
2011-10-27 9:55 ` rguenth at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-08-01 14:33 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49865
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |4.7.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/49865] [4.7 Regression] Unnecessary reload causes small bloat
2011-07-27 11:25 [Bug target/49865] New: Unneccessary reload causes small size regression from 4.6.1 sgunderson at bigfoot dot com
` (2 preceding siblings ...)
2011-08-01 14:33 ` rguenth at gcc dot gnu.org
@ 2011-10-27 9:55 ` rguenth at gcc dot gnu.org
2011-11-24 17:55 ` jakub at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-10-27 9:55 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49865
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2011-10-27
CC| |vmakarov at gcc dot gnu.org
Known to work| |4.6.2
Ever Confirmed|0 |1
Known to fail| |4.7.0
Severity|normal |minor
--- Comment #3 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-10-27 09:54:39 UTC ---
Confirmed. The load is CSEd but the reg has a REG_EQUIV note pointing
to the MEM and is reloaded. An IRA regression.
Vlad, can you investigate if there is a bug?
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/49865] [4.7 Regression] Unnecessary reload causes small bloat
2011-07-27 11:25 [Bug target/49865] New: Unneccessary reload causes small size regression from 4.6.1 sgunderson at bigfoot dot com
` (3 preceding siblings ...)
2011-10-27 9:55 ` rguenth at gcc dot gnu.org
@ 2011-11-24 17:55 ` jakub at gcc dot gnu.org
2011-12-13 19:41 ` vmakarov at redhat dot com
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-11-24 17:55 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49865
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-11-24 16:59:03 UTC ---
Started with http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=171649
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/49865] [4.7 Regression] Unnecessary reload causes small bloat
2011-07-27 11:25 [Bug target/49865] New: Unneccessary reload causes small size regression from 4.6.1 sgunderson at bigfoot dot com
` (4 preceding siblings ...)
2011-11-24 17:55 ` jakub at gcc dot gnu.org
@ 2011-12-13 19:41 ` vmakarov at redhat dot com
2011-12-15 13:46 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: vmakarov at redhat dot com @ 2011-12-13 19:41 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49865
Vladimir Makarov <vmakarov at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |vmakarov at redhat dot com
--- Comment #5 from Vladimir Makarov <vmakarov at redhat dot com> 2011-12-13 19:38:16 UTC ---
I can not reproduce it on the current trunk (rev. 182263). The recent ira
patches might fix it. The code generated on the current trunk is
pushl %ebp
.cfi_def_cfa_offset 8
.cfi_offset 5, -8
movl %esp, %ebp
.cfi_def_cfa_register 5
pushl %edi
.cfi_offset 7, -12
movl $1024, %ecx
xorl %eax, %eax
movl 8(%ebp), %edi
rep stosl
movl 8(%ebp), %eax
movl $0, 4096(%eax)
popl %edi
.cfi_restore 7
popl %ebp
.cfi_restore 5
.cfi_def_cfa 4, 4
ret
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/49865] [4.7 Regression] Unnecessary reload causes small bloat
2011-07-27 11:25 [Bug target/49865] New: Unneccessary reload causes small size regression from 4.6.1 sgunderson at bigfoot dot com
` (5 preceding siblings ...)
2011-12-13 19:41 ` vmakarov at redhat dot com
@ 2011-12-15 13:46 ` jakub at gcc dot gnu.org
2011-12-20 21:32 ` vmakarov at gcc dot gnu.org
2012-01-03 12:59 ` jakub at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-12-15 13:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49865
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-12-15 13:39:58 UTC ---
Well, that is the "bad" sequence.
Until r171648 instead of two movl 8(%ebp), %eX insns (one before rep stosl, one
after) there was just one of those and one movl %eA, %eB register move.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/49865] [4.7 Regression] Unnecessary reload causes small bloat
2011-07-27 11:25 [Bug target/49865] New: Unneccessary reload causes small size regression from 4.6.1 sgunderson at bigfoot dot com
` (6 preceding siblings ...)
2011-12-15 13:46 ` jakub at gcc dot gnu.org
@ 2011-12-20 21:32 ` vmakarov at gcc dot gnu.org
2012-01-03 12:59 ` jakub at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: vmakarov at gcc dot gnu.org @ 2011-12-20 21:32 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49865
--- Comment #7 from Vladimir Makarov <vmakarov at gcc dot gnu.org> 2011-12-20 21:29:40 UTC ---
Author: vmakarov
Date: Tue Dec 20 21:29:36 2011
New Revision: 182553
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182553
Log:
2011-12-20 Vladimir Makarov <vmakarov@redhat.com>
PR target/49865
* ira-costs.c (find_costs_and_classes): Prefer registers even
if the memory cost is the same.
Modified:
trunk/gcc/ChangeLog
trunk/gcc/ira-costs.c
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/49865] [4.7 Regression] Unnecessary reload causes small bloat
2011-07-27 11:25 [Bug target/49865] New: Unneccessary reload causes small size regression from 4.6.1 sgunderson at bigfoot dot com
` (7 preceding siblings ...)
2011-12-20 21:32 ` vmakarov at gcc dot gnu.org
@ 2012-01-03 12:59 ` jakub at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-01-03 12:59 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49865
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-01-03 12:58:17 UTC ---
Fixed, thanks.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2012-01-03 12:59 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-27 11:25 [Bug target/49865] New: Unneccessary reload causes small size regression from 4.6.1 sgunderson at bigfoot dot com
2011-07-27 11:39 ` [Bug target/49865] Unnecessary " sgunderson at bigfoot dot com
2011-07-27 17:29 ` [Bug target/49865] [4.7 Regression] Unnecessary reload causes small bloat sgunderson at bigfoot dot com
2011-08-01 14:33 ` rguenth at gcc dot gnu.org
2011-10-27 9:55 ` rguenth at gcc dot gnu.org
2011-11-24 17:55 ` jakub at gcc dot gnu.org
2011-12-13 19:41 ` vmakarov at redhat dot com
2011-12-15 13:46 ` jakub at gcc dot gnu.org
2011-12-20 21:32 ` vmakarov at gcc dot gnu.org
2012-01-03 12:59 ` jakub at gcc dot gnu.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).