Tech News
← Home  ·  All topics

Compiler Optimization

4 GoKawiil briefs on this topic · RSS for compiler optimization

GCC Blog Post Details How the Compiler Lowers Switch Statements

A technical blog post examines how GCC translates C switch statements into machine code, going beyond simple decision trees. It shows GCC building jump tables for compact case values, including cases offset by a constant, and notes that most of these optimizations also apply to clang except for one technique called bitset lowering.

Developer uses brute-force superoptimization to simplify FPU bit-twiddling function

A developer building a floating-point library needed a function returning the lowest set bit of a float's mantissa, but the straightforward bitwise algorithm failed on powers of two, requiring a slow conditional branch. Unable to find a branch-free formula by hand, they built a brute-force search that tests short sequences of integer operations against representative test cases, adding counterexamples when a candidate formula fails.

Technical series explains second phase of profile-guided optimization in compiler builds

A blog post details how profile-guided optimization (PGO) works in its second installment, describing a two-pass compilation process where an instrumented first build records per-edge counters across branches, loops, and call sites. The author explains how these fine-grained counts feed into the compiler's second-pass decisions, starting with inlining choices that can override static size and cost heuristics based on actual execution frequency.

Programista Magazine Reprints 2013 Guide on Writing Efficient C++ Code

A 2013 article originally published in Programista magazine (issue 4/2013) discusses techniques for writing high-performance C++ code, emphasizing that choosing a native language alone does not guarantee efficiency. The piece outlines why C++ occupies a middle ground between high-level convenience and low-level hardware access, citing manual memory management and lack of a garbage collector as key differentiators from managed languages.