public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/20429] New: Free Lunch?
@ 2005-03-11 18:46 hillcino368 at hotmail dot com
2005-03-11 18:53 ` [Bug c/20429] " pinskia at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: hillcino368 at hotmail dot com @ 2005-03-11 18:46 UTC (permalink / raw)
To: gcc-bugs
Hi,
S1: Dell Diminsion p4 2.533ghz 2gig ram
Batch
g++ %1.c -o %1.exe -O3 -mtune=pentium4
g++ -dumpversion
S2: Dell xps p3 1.0ghz 256 meg ram
g++ %1.c -o %1.exe -O3 -mtune=pentium3
g++ -dumpversion
The following code gives much faster timings for 2000000000 vs 1000000000.
Is this a free-lunch or is it a bug? Also it appears that including the
line sum+=1 causes the loop to run faster on the p4. At any rate Gcc runs
about 30% faster than Lcc. Also the loop
MOV EAX,2000000000
L1:
DEC EAX
JNZ L1
A386 takes 1.21 sec on S1
Gcc is truly a code optimizer.
[CODE]
#include <stdio.h>
#include <time.h>
#define timer clock()/1000.0
float t1,t2;
unsigned long count (unsigned long);
unsigned long billions = 2000000000;
int main()
{
t1=timer;
printf("%u",count(2000000000));
//printf("%u",count(1000000000));
//printf("%u",count(billions));
t2=timer;
printf("%s%G\n"," Sec = ",t2-t1);
getchar();
return 0;
}
unsigned long count (unsigned long i)
{
unsigned long sum;
sum=0;
for(;i>0;i--)
{
sum +=1;
}
return sum;
}
[/CODE]
Test 2000000000
S1 output -> 2000000000 Sec = 0.031
S2 output -> 2000000000 Sec = 0.18
Test 1000000000
S1 output -> 1000000000 Sec = 0.484
S2 output -> 1000000000 Sec = 2.103
Test billions = 2000000000
S1 output -> 2000000000 Sec = 1.218
S2 output -> 2000000000 Sec = 4.486
Test sum +=1; commented out for 2000000000
S1 output -> 0 Sec = 0.984
S2 output -> 0 sec = 4.186
Test sum +=1; commented out for billions = 2000000000
S1 output -> 0 Sec = 0.968
S2 output -> 0 sec = 4.155
--
Summary: Free Lunch?
Product: gcc
Version: 3.4.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: hillcino368 at hotmail dot com
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20429
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c/20429] Free Lunch?
2005-03-11 18:46 [Bug c/20429] New: Free Lunch? hillcino368 at hotmail dot com
@ 2005-03-11 18:53 ` pinskia at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-03-11 18:53 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-03-11 18:53 -------
Well it changes the loop into:
.L5:
incl %eax
cmpl %eax, %edx
jne .L5
so yes this is free lunch.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20429
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-03-11 18:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-11 18:46 [Bug c/20429] New: Free Lunch? hillcino368 at hotmail dot com
2005-03-11 18:53 ` [Bug c/20429] " pinskia 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).