Re:The Art of Picking Intel Registers (2003)
by userbinator on Monday April 23, 2018 @07:02AM
(#16902247)
In my experience, cache matters a lot and compilers aren't smart enough to figure out what parts of the code are time-critical and what parts aren't, so they just use the fastest (and sometimes significantly bigger) instruction sequences everywhere. Optimising non-critical-path code by making it smaller even if it's somewhat slower can actually make the program as a whole faster, since the cache misses decrease.
On Ivybridge and later the string instructions are actually faster than the equivalent unrolled instructions. https://news.ycombinator.com/item?id=12353455
1/ There are edge cases like when the code is very big then less code might fit in the cache better or perhaps dispatch better .. but probably not many.