The dhrystone benchmark is crap.
That benchmark is a derivate of the original 1988 dry.c which was composed by two separate .c files.
Those two files were kept separate to avoid explicitly the compiler to inline function.
example, assume to write a tool to benchnark the integer math, so we slipt it in mul.c and div.c with this functions:
Code:
int mul(int a, int b)
{
return a * b;
}
Code:
int div(int a, int b)
{
return a / b;
}
and from our main call:
Code:
int test(int x)
{
for(int i = 1; i < x; i++)
div(mul(i, 100), 25);
}
inlining those two functions will generate something like:
Code:
int test(int x)
{
for(int i = 1; i < x; i++)
(i * 100) / 25;
}
which the compiler optimize as
Code:
int test(int x)
{
for(int i = 1; i < x; i++)
i * 4;
}
With a huge performance gain.
While LTO is good in real use, it can fake many benchmarks, so I'll use it only on real world scenarios.