3 ms·
Imo compilers should only optimize specific functions which are known to be a code hotspot.
by andrewchambers 11y ago
Imo compilers should only optimize specific functions which are known to be a code hotspot.
- Dewie3 11y agoWell in that case... if you consider optimizing non-hotspots as "bloat"(?) then you are coming at this from a whole other viewpoint than most of us who have embraced optimizing compilers. :-)
- pcwalton 11y agoThat will result in very poorly-performing code. I liked DannyBee's quote (paraphrased): "Most applications have flat profiles. They have flat profiles because people have spent a lot of time optimizing them."
- andrewchambers 11y agoThere are times squeezing every last bit of performance is great. I am saying is in general there is no need to run -O3 on a 500 line function which is run once at initialization compared to a compute kernel. Our compilers and languages don't have the granularity to specify this currently. I do want more specialized optimization tools however. Things like automatic super optimizers [1] which can be targeted by programmers with special directives. [1] http://theory.stanford.edu/~sbansal/superoptimizer.html http://theory.stanford.edu/~sbansal/superoptimizer.html
- e12e 11y agoAccording to a quick google search, both gcc, clang and msvc allow turning off/on optimizations at a function level, via #pragma/attributes?
- andrewchambers 11y agointeresting!