Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: One (silly) question about "C"

Author: Dann Corbit

Date: 17:25:45 02/05/02

Go up one level in this thread


GCC and MS VC++ stink up the joint (blow chunks, as they say), however:
dcorbit@DANNFAST c:/tmp
$ gcc -W -Wall -ansi -pedantic -O3 foo.c
foo.c: In function `main':
foo.c:23: warning: comparison between signed and unsigned

dcorbit@DANNFAST c:/tmp
$ ./a
Expecting a sum of 30830878000000
sum normal:   sum=30830878000000, used 19.427 seconds
sum unrolled: sum=30830878000000, used 8.332 seconds

C:\tmp>cl /W4 /Ox /G6 foo.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

foo.c
foo.c(23) : warning C4018: '<' : signed/unsigned mismatch
Microsoft (R) Incremental Linker Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

/out:foo.exe
foo.obj

C:\tmp>foo
Expecting a sum of 30830878000000
sum normal:   sum=30830878000000, used 19.819 seconds
sum unrolled: sum=30830878000000, used 7.471 seconds


I'll give GCC credit, though.  It managed to do OK when I told it to inline like
a madman:

dcorbit@DANNFAST c:/tmp
$ gcc -W -Wall -ansi -pedantic -O3 -funroll-all-loops foo.c
foo.c: In function `main':
foo.c:23: warning: comparison between signed and unsigned

dcorbit@DANNFAST c:/tmp
$ ./a
Expecting a sum of 30830878000000
sum normal:   sum=30830878000000, used 8.842 seconds
sum unrolled: sum=30830878000000, used 8.392 seconds

So only MS VC++ was uable to do anything useful with the original loop.  But we
should give them credit where credit is due.  They produced the fastest result
for the unrolled loop.



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.