Hacker News new | ask | show | jobs
by 0xFFC 3400 days ago
I am asking this genuinely, I always thought and heard LLVM optimizer is inferior to GCC's. Am I wrong ? is there any scientific benchmark for this ?
3 comments

It's really hard to quantify enormous (millions-of-lines) complex pieces of code that simply. LLVM and GCC take broadly the same approach to optimization: an SSA-based IR with dozens of passes, followed by lowering to a machine-specific IR with many more passes, followed by machine code generation, register allocation, and cleanup optimizations.

Basically, all you can really say is: LLVM is better at some code; GCC is better at other code. The differences are at the level of highly situational details at this point, not broad strokes.

My understanding was that GCC was better in more scenarios most of the time, but now it seems like Clang has caught up. and Maybe Clang 4.0 is even faster in more.

Here are some recent benchmarks from phoronix: http://www.phoronix.com/scan.php?page=article&item=gcc7-clan...

Yeah. But in this kind of tuned benchmark, I doubt clang will do any better across the board - especially not considering the fact that the current programs are likely to be at least somewhat tuned specifically for gcc.
Clang does well enough to be the default compiler for Apple and Google. It can't be that far behind.
Oh yeah, I have no reason to believe it's worse; it's just that I also doubt it's going to help much either.

But... trial and error and all ;-).

I think they make different choices in different situations. My understanding has been that they are generally the same, with one doing much better in different situations.

But I have nothing to back this up. Wouldn't it be cool if the benchmark game provided a datapoint on this?

"If you're interested in something not shown on the benchmarks game website then please take the program source code and the measurement scripts and publish your own measurements."

http://benchmarksgame.alioth.debian.org/play.html#languagex