On Thursday, 23 April 2015 at 01:45:14 UTC, deadalnix wrote:
On Wednesday, 22 April 2015 at 20:36:12 UTC, John Colvin wrote:
Is it even possible to contrive a case where
1) The default initialisation stores are technically dead and
2) Modern compilers can't tell they are dead and elide them and
3) Doing the initialisation has a significant performance
impact?
The boring example is "extra code causes instruction cache
misses".
I'd say it is very unlikely. If the compiler wan't see it, then
it means the code is non trivial, and if it is non trivial, it
is not an extra store that is going to make any difference.
This was my thinking. I guess you could have something like this:
extern(C) void myCheapInitialiser(float*, size_t);
float[256] a;
myCheapInitialiser(a.ptr, a.length);
sort(a);
writeln(a.stride(2).sum());