3 ms·
IME, optimal register allocation isn't so important anymore. In normal code, function bodies are so small that all local variables can be kept in registers. I.e
by bjourne 11y ago
IME, optimal register allocation isn't so important anymore. In normal code, function bodies are so small that all local variables can be kept in registers. I.e, if the # of local variables is small, like 5, then the register allocation is optimal by default. It would be interesting to see before and after assembly code from c functions that gcc generates.
- andrewflnr 11y agoFor extremely optimistic definitions of "normal". Also, if your "five variables" have non-overlapping live ranges, then you might be able to get it down to only 2 or 3 registers, so I wouldn't say it's "optimal by default".
- adrianN 11y agoMaybe if you disable inlining and beat your coworkers up when they add more code to a function. Where I live functions with several hundred lines are still common.
- gpderetta 11y agoAt least C++ depends for its performance on very aggressive inlining of small (often one-line) functions. It is not unlikely that your hundreds of tiny functions become one massive "function" after high level optimization.