Re:What Challenges and Trade-Offs Do Optimising Compilers Face?
by bzbarsky on Friday June 23, 2017 @03:03AM
(#14617458)
Last I checked, gcc in PGO mode can basically do things like "-O2 for hot code, -Os for everything else".
MSVC in PGO/LTO mode will do all sorts of exciting things. For example, in hot code it will detect that a virtual function call is always or nearly always happening with the same vtable pointer and emit a guard on the vtable pointer followed by an inlining of that one particular implementation (with a fallback to a normal virtual call if the guard fails). I'm pretty sure it doesn't do this for all virtual function calls in the program. Even if it only does it for ones where it has "enough data", that would bias towards the hot ones.
Re:What Challenges and Trade-Offs Do Optimising Compilers Face?
by greglindahl on Thursday June 22, 2017 @02:55PM
(#14614420)
PGO can also record loop sizes, which helps with decisions about vectorization, prefetching, non-temporal stores, etc etc. Call counts are useful for inlining and function specialization decisions. I don't know what gcc does, but Open64 does all of the above.
Re:What Challenges and Trade-Offs Do Optimising Compilers Face?
by sanxiyn on Thursday June 22, 2017 @02:48PM
(#14614388)
Not explicitly, but because hot functions get inlined and inlining enables optimizations, something roughly similar does happen.
Re:What Challenges and Trade-Offs Do Optimising Compilers Face?
by Joky on Thursday June 22, 2017 @09:49PM
(#14616640)
> Do compilers really make use of the profile timings to decide to spend more time optimising 'hot' parts of the code with more involved/expensive transformations?
Clang does not AFAIK.
I thought that all it really did, at least on gcc, was record which branches were taken and optimise the code to reflect the common path. Do compilers really make use of the profile timings to decide to spend more time optimising 'hot' parts of the code with more involved/expensive transformations?