Namespace:

So only GDC optimized "pure" functions at all?

I've seen DMD performs some optimizations with "strongly pure" functions that return integral values.

If you have code like:

int sqr(in int x) pure nothrow { return x * x; }

int y = ...
auto r = sqr(y) + sqr(y);

I think DMD replaces that with this, even when inlining is disabled:

int y = ...
auto r = sqr(y) * 2;

Bye,
bearophile

Reply via email to