views:

227

answers:

5

Can you please give me some comparison between C compilers especially with respect to optimization?

+7  A: 

Actually there aren't many free compilers around. gcc is "the" free compiler and probably one of the best when it comes to optimisation, even when compared to proprietary compilers.

Some independent benchmarks are linked from here: http://gcc.gnu.org/benchmarks/

joemoe
There's a few C compilers around, `clang+llvm`, `gcc`, `pcc`, `tcc` to name a few.
dreamlax
A: 

This is a hard question to answer since you did not tell us what platform you are using, neither hardware or os....

But joemoe is right, gcc tend to excel in this field.

(As a side note: On some platforms there are commercial compilers that are better, but since you gain so much more that just the compiler gcc is hard to beat...)

Johan
I am using intel x86 processor with fedora 11
Naga
@Naga Then GCC is an ultimate choice
qrdl
@Naga Yes, gcc is the ultimate choice when using Linux.
Johan
A: 

the Windows SDK is a free download. it includes current versions of the Visual C++ compilers. These compilers do a very good job of optimisation.

steelbytes
Note that the compilers in the free *Visual Studio Express* versions are intentionally crippled when it comes to optimisation. You need to buy the full version if you want even the relatively poor optimisation support that Microsoft provides.
Paul R
@Paul R: I know that _used_ to be true when MS first started the Express versions of VS (and assume still is). but is it true for the compilers in the SDK? not so sure that it is ... need to google it :-)
steelbytes
from http://blogs.msdn.com/windowssdk/ "What’s new in the WinSDK v7.1 release? ... VC++ 2010 RTM compilers/CRT with improved compilation performance and speed. These are the same compilers and toolset that ships with Visual Studio 2010"
steelbytes
@steelbytes: I tested VS 2008 Express recently and found this to be the case. I haven't looked at VS 2010 Express yet to see whether that policy has changed. Note however that VS - even the full version - typically generates poorer code than either gcc or ICC.
Paul R
fine, but my orig post was about the compilers that came with the SDK, not the compilers in Express. Have you tested those?
steelbytes
+1  A: 

I believe Intel allows you to use its ICC compilers under Linux for non-commercial development for free. ICC beats gcc and Visual Studio hands down when it comes to code generation for x86 and x86-64 (i.e. it typically generates faster code, and can do a decent job of auto-vectorization (SIMD) in some cases).

Paul R
It would be better if you elaborated. Shorter compile time, faster programs, smaller code size, etc.? On what benchmarks?
Matthew Flaschen
@Matthew: noted - I've qualified the answer a little further.
Paul R