Guidelines for Writing Efficient C/C++ Code
With ineffective programming, even a perfect compiler can not generate efficient code. This paper focuses on the hows and whys of programming with today's modern compilers and how to get good performance out of them. Examples are given to illustrate how simple source code transformations can result in big savings regardless of the compiler used. The paper covers choice of data types, variable scopes, the restrict keyword, floating point arithmetic, assembly statements, packing, and loop optimizations. This paper has been updated to reflect trends in optimizations and the open source GNU compilers.