arXiv(opens in a new tab)cs.PLAug 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2608.20137

Formal Performance and Compile Time Guarantees for Compiler Optimization Heuristics

Nikil V. Shyamsunder

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Modern optimizing compilers rely on heuristic search algorithms for NP-hard optimization problems, which can result in poor generated-code performance and long or unpredictable compile times. These are considered bugs by users, but verified compilers rarely reason beyond semantic preservation. We propose verifying performance and compile time properties of compiler passes. As a proof-of-concept, we formulate inline expansion using a cost model estimating instruction-cache performance. We mechanize this in Rocq, prove semantic preservation of the inlining transformation, and verify the algorithm’s monotone improvement, convergence-time bound, and performance bounds for intermediate and final solutions.

I Introduction

Compilers are evaluated on correctness, the performance of generated code, and the compile time required to achieve it. Verified compilers have traditionally focused exclusively on correctness. CompCert, for example, leverages the technique of bisimulation proofs for semantic preservation: a source program step must correspond to a sequence of target steps with the same behavior, and vice versa [1]. Recent extensions use quantitative reasoning to guarantee resource availability on the target machine, such as stack-space or memory bounds [2, 3]. These rule out a large class of miscompilations, but do not reason about the optimality of the algorithms: how close a pass’s output is to the best result in its search space.

In practice, excessively poor performance of generated code and long or unpredictable compile times are also treated as compiler bugs, revealing a mismatch between what verification guarantees and what users expect from a compiler. These bugs are often caused by global optimization passes where compilers rely on heuristics, such as register allocation and inline expansion in traditional software compilers [4, 5, 6]. A heuristic may find an excessively suboptimal solution or search too long for an acceptable solution. This problem is magnified in compilers for less conventional targets, such as ML frameworks and hardware toolchains, where the abundance of NP-hard problems such as tensor layout, hardware scheduling, placement, and routing means a poor search heuristic can miss high-performance transformations or incur long compile times [7, 8, 9, 10, 11]. In all of these settings, the compiler runs without formal guarantees that search will conclude quickly or find an effective solution.

For an entire production compiler, generated-code quality and compile time are emergent properties of many interacting passes and cost models, making them difficult to state as a single specification. Instead, we aim for guarantees about the particular passes where poor generated-code quality and runaway compile time are most likely to arise. Specifically, we focus on verifying two kinds of properties:

  • Performance bounds. To rule out excessively poor generated code, we want a machine-checked bound on a pass’s output relative to the best solution in its search space under some cost model. Even when no such bound is found, the formal reasoning is itself informative: it tends to pinpoint the input configurations under which the pass degrades, exposing the areas worth ameliorating.
  • Convergence time and progress bounds. We want guarantees that a compiler optimization terminates in a bounded number of steps, and that varying the level of optimization through controls like -O{N} flags gives predictable compile time/code-performance tradeoffs.

We report our initial findings on a simple pass and cost model, as a first step toward providing production-ready algorithms that are provably correct and performant for critical passes.

References (9)