public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/47186] New: -O2 moves invariant address load INTO loop
@ 2011-01-06 9:43 gcc.hall at gmail dot com
2021-07-29 22:47 ` [Bug target/47186] " pinskia at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: gcc.hall at gmail dot com @ 2011-01-06 9:43 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47186
Summary: -O2 moves invariant address load INTO loop
Product: gcc
Version: 4.5.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: gcc.hall@gmail.com
Host: Fedora 14
Target: i?86-*-*
Build: 4.5.1 20100924 (Red Hat 4.5.1-4)
gcc -O1 try.c -S -masm=intel -o try.s
In the example below, the address load to esi for the movsd is moved into the
loop when -O2 is used. With -O1 its outside the loop.
Perhaps this is something to do with scheduling? I tried with various x86
targets and it always happened, although the position of the address load
within the loop changed between atom and core2 for example.
--------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int mike[100], joe[100];
int main( int argc, char *argv[] )
{
int i;
for( i = 0; i < 100; ++i )
mike[i] = rand();
memcpy( joe, mike, sizeof(joe) );
}
--------------------------------------
Compile with -O1 produces ...
.L2:
call rand
mov DWORD PTR mike[0+ebx*4], eax
add ebx, 1
cmp ebx, 100
jne .L2
mov edi, OFFSET FLAT:joe
mov esi, OFFSET FLAT:mike
mov ecx, 100
rep movsd
Now repeat with -O2, and esi is loaded within the loop
.L2:
call rand
mov esi, OFFSET FLAT:mike
mov DWORD PTR mike[0+ebx*4], eax
add ebx, 1
cmp ebx, 100
jne .L2
mov ecx, ebx
mov edi, OFFSET FLAT:joe
rep movsd
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug target/47186] -O2 moves invariant address load INTO loop
2011-01-06 9:43 [Bug target/47186] New: -O2 moves invariant address load INTO loop gcc.hall at gmail dot com
@ 2021-07-29 22:47 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-29 22:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47186
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |missed-optimization
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Looks to be fixed in 5.1+.
5.1-7.3 produces:
.L2:
call rand
addl $4, %ebx
movl %eax, -4(%ebx)
cmpl $mike+400, %ebx
jne .L2
8.1+ produces
.L2:
call rand
movl %eax, mike(,%ebx,4)
addl $1, %ebx
cmpl $100, %ebx
jne .L2
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-07-29 22:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-06 9:43 [Bug target/47186] New: -O2 moves invariant address load INTO loop gcc.hall at gmail dot com
2021-07-29 22:47 ` [Bug target/47186] " pinskia 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).