inline functions

bearophile bearophileHUGS at lycos.com
Sat Mar 26 05:25:09 PDT 2011


Answer for Jonathan M Davis and Caligo:

I far as I remember you need to use -finline-functions on GDC to perform inlining.

-O3 implies inlining, on GCC, and I presume on GDC too.

Inlining is a complex art, the compilers compute a score for each function and each function call and decide if perform the inlining. There are many situations where inlining harms performance, and it's not just a matter of code cache pressure (this list of problems is not complete: http://en.wikipedia.org/wiki/Inlining#Problems ). DMD inlining is  in many ways weak compared to GCC/LLVM (GDC/LDC) ones. 32 bit GDC/DMD are also able use SSE+ registers, that sometimes give performance gains.

To discuss a bit about the dot product performance (that's present in Phobos too) I suggest to pull out and show the assembly code. Timings alone don't suffice. I may produce some assembly later, if I create a little test program or if Caligo posts here one.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list