The article discusses undefined behavior in C++, explaining how it occurs when programs violate language rules, leading to unpredictable outcomes that compilers may exploit for optimization. It covers common causes like signed integer overflow, out-of-bounds access, and type punning, while noting that undefined behavior differs from implementation-defined and unspecified behavior.
#compiler-optimization
14 items
The paper presents a novel approach to SSA (Static Single Assignment) form that eliminates the need for dominance information in higher-order programs. It introduces a new algorithm that works for functional languages with first-class functions and nested lexical scopes. The method provides a simpler alternative to traditional SSA transformations while maintaining correctness.
Compilers use multiplication by reciprocal constants to replace expensive division operations with faster multiplication. This optimization technique leverages integer arithmetic and fixed-point representations to improve performance while maintaining accuracy.
The article discusses how compilers decide to unroll loops for performance optimization, examining the factors and trade-offs involved in this compiler optimization technique.
Loop unswitching is a compiler optimization technique that duplicates loops to eliminate conditional branches inside them. This can yield performance improvements by reducing branching overhead and enabling better instruction-level parallelism.
Loop-invariant code motion is a compiler optimization technique that moves code outside of loops to improve execution speed. This optimization identifies computations that produce the same result in every loop iteration and relocates them before or after the loop.
Loop-invariant code motion (LICM) can fail when aliasing prevents the compiler from safely moving code outside loops. This occurs when the compiler cannot determine if memory accesses might overlap, creating uncertainty about code invariance.
The article discusses how inlining, where a compiler copies function code directly into calling locations, can be an effective optimization technique. It explains that this approach eliminates function call overhead and enables further optimizations.
Partial inlining is a compiler optimization technique that allows selective inlining of function code rather than requiring all-or-nothing decisions. This approach enables compilers to inline only the most beneficial parts of a function while keeping less critical sections as separate calls.
The article examines different optimization techniques compilers can apply to switch statements, exploring various approaches to improve performance and efficiency in code execution.
Thank you
2.0The 2025 Advent of Compiler Optimisation has concluded. The event featured daily compiler optimization challenges throughout December.
The blog post explains load and store forwarding in the Toy Optimizer, a technique that eliminates redundant loads by modeling the heap at compile-time. It demonstrates how to cache load results and invalidate them appropriately when stores occur, using abstract interpretation over traces.
The article describes implementing type-based alias analysis (TBAA) in the Toy Optimizer. It explains using hierarchical heap effect representation with integer ranges to model type relationships and check for aliasing through range overlap queries. This improves alias analysis by leveraging compile-time type information.
The author describes creating a fuzzer for the Toy Optimizer to automatically detect correctness bugs. The fuzzer generates random programs, verifies them against an unoptimized version, and tests the optimizer's output. It successfully catches bugs when key correctness components are disabled.