1

I write some C code by myself and I compile them by LLVM or gcc.

Nowadays, I compiled two different executable from two compiler (LLVM and gcc), and ran 100,000 times on both of them.

I found that the performance of executable from gcc always better than LLVM one.

I know they are different type of compiler even different architecture.

But why gcc always beat LLVM on performance? What is the reason?

sepp2k
  • 363,768
  • 54
  • 674
  • 675
Shane
  • 337
  • 1
  • 10

1 Answers1

1

So this is your main question


Question

Is it normal that the performance of executable compiled from gcc better than one compiled from LLVM?


Although an interesting but apparently a very broad question. Because compiler performance depends on a lot of factors.

  • It depends heavily on your application.
  • It depends on the underlying architecture and processor
  • .........and many more factors

In addition to that, there are well established benchmarks to verify the compilers performance. With one application binary performing better is not the right benchmark and hence not an established result.

However, since application performance (program performance) is affected by the choice of the compiler, it completely makes sense that in your case you see GCC performance better than LLVM, however, it's not bound to happen always for every application.

For your further understanding, please check this:

BZKN
  • 1,499
  • 2
  • 10
  • 25