3 ms·
Not saying that this particular optimization is not generally beneficial; however I'm always a bit wary of local code size increasing optimizations. Instruction
by vardump 11y ago
Not saying that this particular optimization is not generally beneficial; however I'm always a bit wary of local code size increasing optimizations. Instruction cache miss costs a lot more than a mispredicted branch. Increasing code size creates more opportunities for a cache miss to occur.
To really know whether or not this is a win, you need to test this in the context of the whole thing. Microbenchmarks often give a wrong idea. They're not usually run under stress of certain CPU resources such as L1C, L1D, TLB, etc. But in real code the situation is different. Other code also needs those cache entries and may very well perform worse because of a local optimization elsewhere bottlenecking execution by taking up resources.