News for hackers. Stuff that matters.
Re:Brilliant Hardware in the Valley of the Software Slump by saagarjha on Sunday June 14, 2020 @01:28AM (#23515344)
Optimizing compilers will occasionally make these decisions, but often they don’t have to because the processor will make them themselves. Modern Intel processors already do macro fusion for the common pattern of “test this and jump the result”, micro-optimizing by changing the direction your loop runs in is generally not a good idea unless you really know what you are doing, have tested the code, and intend to never change your compiler or processor ever again. (And it still depends on how your CPU is feeling that day.) In general, the kinds of things you are mentioning produce in their best case a minor win over the optimizing compiler, and if you’re not checking whether they actually work, often make no difference or do much worse most of the time. And they often come at a huge readability/maintainability cost, so really you have to ask yourself if it’s really worth making these superstitious microptimizations.

There are no comments on this comment yet.