DMD generates slow code in simple situations such as:
double foo(double x) { return x*2; }
It creates a floating-point constant 2.0, and then generates an FMUL to multiply by it. It's particularly slow in the 80-bit real case, where two instructions (FLD and FMULP) are required.
The attached patch generates the fast and simple FADD ST(0), ST; instead. It only applies to float,double, real, not to complex numbers.
Comment #1 by clugdbug — 2009-04-24T15:13:08Z
Created attachment 338
Patch against DMD2.029
This will be a useful step towards further optimisation of pure functions with real return values.