You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
intcpu_execute_event()
{
unsignedlonglong c;
unsignedlonglong l;
double t;
unsignedlonglong n=0;
/* So far we're using very simple test prime number tests in 64bit */for(c=3; c < max_prime; c++)
{
t = sqrt((double)c);
for(l = 2; l <= t; l++)
if (c % l == 0)
break;
if (l > t )
n++;
}
return0;
}
n is not used, therefore everything can be and is optimized away. https://godbolt.org/z/8qbGhe9ba
For some reason outside of compiler explorer, GCC doesn't optimize it away:
FYI, This part of a larger pull request implements it this way, via storing TLS variable. It was noticed, because MSVC compiler also optimized away the function.
In
n is not used, therefore everything can be and is optimized away. https://godbolt.org/z/8qbGhe9ba
For some reason outside of compiler explorer, GCC doesn't optimize it away:
The result is
Clang:
CGG:
To fix this:
benchmark::DoNotOptimize(std::move(n));
I have no clue how to use autogen so I'm not goint to do that.
The text was updated successfully, but these errors were encountered: