public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/35776] New: Simple loop isn't optimized well
@ 2008-03-31 17:04 yuri at tsoft dot com
2008-04-01 11:06 ` [Bug tree-optimization/35776] " rguenth at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: yuri at tsoft dot com @ 2008-03-31 17:04 UTC (permalink / raw)
To: gcc-bugs
I have a C code:
void f();
void i(unsigned n) {
while (n-- > 0) {
f();
}
}
Which when compiled with -O3 on i586 produces the assembly:
i:
pushl %ebp
movl %esp, %ebp
pushl %esi
movl 8(%ebp), %esi
pushl %ebx
testl %esi, %esi
je .L5
xorl %ebx, %ebx
.p2align 4,,7
.L4:
addl $1, %ebx
call f
cmpl %esi, %ebx
jne .L4
.L5:
popl %ebx
popl %esi
popl %ebp
ret
And obviously shorter assembly with one less instruction in the loop is:
i:
pushl %ebp
movl %esp, %ebp
pushl %esi
movl 8(%ebp), %esi
testl %esi, %esi
je .L5
.p2align 4,,7
.L4:
call f
dec %esi
jl .L4
.L5:
popl %esi
popl %ebp
ret
This is a very short and basic loop occurring in programs many times.
That's why this should be optimized very well.
--
Summary: Simple loop isn't optimized well
Product: gcc
Version: 4.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: yuri at tsoft dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35776
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug tree-optimization/35776] Simple loop isn't optimized well
2008-03-31 17:04 [Bug c/35776] New: Simple loop isn't optimized well yuri at tsoft dot com
@ 2008-04-01 11:06 ` rguenth at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-04-01 11:06 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from rguenth at gcc dot gnu dot org 2008-04-01 11:05 -------
4.3 produces
.L5:
call f
subl $1, %ebx
jne .L5
thus fixed.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Component|c |tree-optimization
Keywords| |missed-optimization
Resolution| |FIXED
Target Milestone|--- |4.3.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35776
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-04-01 11:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-31 17:04 [Bug c/35776] New: Simple loop isn't optimized well yuri at tsoft dot com
2008-04-01 11:06 ` [Bug tree-optimization/35776] " rguenth 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).