3 ms·
> put it into its own object file and tweak the compiler flags as necessary This is a good approach, as are finer-grained optimisation pragmas & attributes, #i
by evincarofautumn 11y ago
> put it into its own object file and tweak the compiler flags as necessary
This is a good approach, as are finer-grained optimisation pragmas & attributes, #ifdeffed as needed.
Ideally, I’d like the compiler to do only cursory optimisations by default, just enough that I can read the assembly and not say “wow, this is stupid”.
For anything else, I’d rather have a dialogue with the profiler & compiler heuristics, wherein they suggest optimisations, but I choose which ones I want using optimisation pragmas, and the compiler does the grunt work of program transformation.
For example, the compiler would say “this function is only ever called in cold paths; I suggest adding the ‘cold’ attribute” or “this loop can be vectorized; I suggest adding the ‘vectorize’ attribute”.