inlining or not inlining...

bearophile bearophileHUGS at lycos.com
Fri Feb 11 12:59:54 PST 2011


Walter:

> bearophile wrote:
> >> While in isolation that's a good idea, how far should it be taken? Should the 
> >> compiler emit information on which variables wound up in which registers, and 
> >> why? What about other of the myriad of compiler optimizations?
> > 
> > Inlining is an important optimization, so give this information to the programmer is a good start.
> 
> Register allocation is far more important than inlining. Why not give 
> information about why a variable was not enregistered?

Some answers:
- I am not asking for this information because it is harder to use for me. If a function was inlined or not is simpler to use for me.
- In my D1 code I have found two or more problems caused by failed inlining. So this is of my interest.
- If you want to optionally give the register information to the programmer, then do it. I am not going to stop you :-) Some people need this information, like when you implement the little kernels of a very fast FFT.
- Register allocation on 32 bit CPUs is not the same as on 64 bit ones. On 64 bit you have many more registers (and you have SSE registers, and now AVX too), so in many situations the register pressure is lower.
- There are two groups of register allocation algorithms. The very fast ones, and the more precise ones. You even have perfect ones. Experience has shown that the difference in runtime performance between the precise algorithm and the perfect ones is often about 5% (this measured on LLVM(. This means that with LLVM you will probably never see a significant improvement of automatic register allocation, because it's as good as it gets, it's kind of a solved problem. In JITs like in the JavaVM you have register allocation algorithms that are less precise but faster. Here there is space for possible future improvements. And then, there are the special situations, like implementing those little FFT kernels, or when you want to compile a functional language like Haskell into assembly. In such situations even the very good automatic register allocation algorithms are not good enough. In this case information about register allocation is useful, but this is a very specialized usage. The need to know about inlining is in my opinion more common.

Bye,
bearophile


More information about the Digitalmars-d mailing list