[LLVMdev] LLVM vs GCC binary performance

Duncan Sands baldrick at free.fr
Fri Mar 11 06:53:07 PST 2011


Hi Yuli,

> As a developer I'm very excited and interested in the LLVM project. Though my
> knowledge of the details is cursory my general understanding is that the SSA
> code that LLVM front ends produce is supposed to allow for optimizations that
> are unfeasible in GCC.

not so, GCC also uses SSA form.  I'm not aware of any optimization that LLVM can
do that GCC couldn't do if it tried.

  I also expect most important optimizations from GCC would
> have been incorporated into LLVM by now since GCC code is open for everyone to
> see.

This is not the case.  You make it sound like reimplementing optimizations is
a five minute job while that is very far from true!  Not to mention that GCC is
a moving target: it is being worked on too and getting nice improvements all the
time.  For example it has auto-vectorization support while LLVM does not.  Also,
don't forget that LLVM is not simply GCC written in C++: it makes a lot of
different design choices to GCC, and has a bunch of use cases that GCC does not,
for example, the ability to JIT code.  The LLVM developers may feel that the way
GCC solved some problem is not the best way for LLVM to solve it, and even if
they think GCC's approach to some problem is great it nonetheless might be hard
to do things the same in LLVM due to the different design.

  Therefore I'm surprised to see that in most benchmarks LLVM produces
> binaries are 10-15% slower than their GCC counterparts.

While in my experience this used to be pretty systematically true on x86
linux, nowadays it is much more hit and miss: I see some programs running
faster when compiled with LLVM, and others running faster when compiled with
GCC.  On the whole I would say that on my machine GCC usually results in faster
programs.

   Would you mind
> explaining the main reasons for why this is the case?

On the whole GCC produces excellent code.  Many fine engineers have worked hard
on it for many years, and it shows.  Doing better than GCC is difficult.

Also, what remains to be
> done for LLVM to surpass GCC in terms of binary performance?

There's no magic bullet.  The things to improve that would give you the most
bang for your buck are probably the code generator and auto-vectorization.
Increasing the number of developers would be helpful.

Ciao, Duncan.



More information about the llvm-dev mailing list