Sometimes, I read statements such as “C compiler x is always superior to y”. But I like to my make my choices based on hard data. I chose the industry-standard
CoreMark benchmark for this. Instead of benchmarking different machines (as I did
elsewhere), I built CoreMark with different compilers and ran it on the
same machine (ST @ 8 MHz). Since CoreMark is designed to contain many algorithmic “building blocks” commonly found in real-world applications (read the
whitepaper if you’re interested), its performance imho is a good indication of the overall quality of the compiler’s code generation.
Here is the number of iterations per second, achieved with different compilers. Higher is better:
Code: Select all
Pure C 1.1 : 0.81
vbcc 0.9hp2 (-O3): 1.19
gcc 2.9.5 (-O2): 1.28
gcc 4.6.4 (-O2): 1.72
gcc 8.2.1 (-O2): 1.92
gcc 9.3.1 (-O2): 1.92
The best version is more than twice as fast as the slowest version. This shows that it’s important to compare compilers. But by all means, gather your own data; benchmark your specific application.
PS: The vbcc version was built with “-O3” for a reason. You see, CoreMark checks its results and it reports an error when I build it with vbcc 0.9h and “-O2”. There must be bug in the code generation. Not very trustworthy, imho.