Compiler Optimization

There are quite a few important optimizations that a decent compiler can apply on your behalf without requiring any source code intervention on your part. The first optimization that comes to mind is register allocation. Loading and storing a variable is fastest when that variable resides in a register. Otherwise, we are going to have to spend a few cycles fetching this variable from elsewhere. If an update is performed, we will also need to store it back where it came from. In that case, it gets even worse if the variable is not in the cache. A single memory access on modern architecture is upwards of five cycles. All this is avoided if the variable resides in a register. Register allocation is an important optimization ...

Get Efficient C++ Performance Programming Techniques now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.