Home → Magazine Archive → February 2020 (Vol. 63, No. 2) → Optimizations in C++ Compilers → Abstract

Optimizations in C++ Compilers

By Matt Godbolt

Communications of the ACM, Vol. 63 No. 2, Pages 41-49
10.1145/3369754

[article image]


back to top 

Compilers are a necessary technology to turn high-level, easier-to-write code into efficient machine code for computers to execute. Their sophistication at doing this is often overlooked. You may spend a lot of time carefully considering algorithms and fighting error messages but perhaps not enough time looking at what compilers are capable of doing.

This article introduces some compiler and code generation concepts, and then shines a torch over a few of the very impressive feats of transformation your compilers are doing for you, with some practical demonstrations of my favorite optimizations. I hope you will gain an appreciation for what kinds of optimizations you can expect your compiler to do for you, and how you might explore the subject further. Most of all, you may learn to love looking at the assembly output and may learn to respect the quality of the engineering in your compilers.

1 Comments

Alexey Gorkov

The line in the code block (c) on page 42
for (int iTimes1234 = 0; iTimes1234 < 100 * iTimes1234 += 1234) {

should probably be
for (int iTimes1234 = 0; iTimes1234 < 100 * 1234; iTimes1234 += 1234) {

Displaying 1 comment