hn.today

Performance of a formally-verified C compiler vs. GCC -O2

ut-infraai.github.io16 points2 comments
Screenshot of Performance of a formally-verified C compiler vs. GCC -O2

CompCert is a C compiler whose optimizations are backed by machine-checked proofs, making it attractive for safety-critical software but often slower than GCC. The investigation asks whether that gap comes mainly from CompCert’s strict models of C and x86-64 or from optimizations it lacks. Disabling GCC’s signed-overflow, aliasing, fused multiply-add, and SIMD optimizations still leaves CompCert 26% slower on its own benchmark suite and 54% slower on PolyBench, close to the original gaps. The results therefore point to missing optimizations, rather than semantic restrictions, as the main cause. To locate the losses, the researchers edited generated assembly and measured the effects. Removing redundant zero-extension instructions improved AES runtime by 9%; combined with loop-invariant code motion, the improvement reached about 20%, slightly beating GCC -O2. In another case, zeroing an SSE register before scalar operations broke a false hardware dependency and sped up an nbody test by 40%.

The work also explains two ways CompCert can prove new optimizations correct. In direct verification, the optimization itself is written in Rocq and proved to preserve program behavior; this suits clear dataflow analyses but makes changes to complex heuristics costly to prove. Translation validation instead lets ordinary OCaml code perform a transformation, while a verified Rocq checker confirms that the result preserves behavior for each function. CompCert already uses this approach for register allocation and block layout. The comparison suggests that improving performance need not require weakening formal guarantees: many useful transformations fit the existing semantics, but adding them requires choosing a proof strategy that supports practical development.

Read on ut-infraai.github.io2 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.