Skip to main content
QUICK REVIEW

[Paper Review] Souper: A Synthesizing Superoptimizer

Raimondas Sasnauskas, Yang Chen|arXiv (Cornell University)|Nov 13, 2017
Parallel Computing and Optimization TechniquesComputer Science17 references42 citations
TL;DR

Souper is a synthesizing superoptimizer that automatically discovers and applies novel compiler optimizations by using SAT/SMT solvers to search for equivalent, more efficient code sequences in a functional, control-flow-free intermediate representation (IR) resembling LLVM IR. It reduces Clang binary size by 4.4% (3 MB) and has led to hand-implemented optimizations in both LLVM and Microsoft Visual C++.

ABSTRACT

If we can automatically derive compiler optimizations, we might be able to sidestep some of the substantial engineering challenges involved in creating and maintaining a high-quality compiler. We developed Souper, a synthesizing superoptimizer, to see how far these ideas might be pushed in the context of LLVM. Along the way, we discovered that Souper's intermediate representation was sufficiently similar to the one in Microsoft Visual C++ that we applied Souper to that compiler as well. Shipping, or about-to-ship, versions of both compilers contain optimizations suggested by Souper but implemented by hand. Alternately, when Souper is used as a fully automated optimization pass it compiles a Clang compiler binary that is about 3 MB (4.4%) smaller than the one compiled by LLVM.

Motivation & Objective

  • To address the high engineering cost of developing and maintaining complex middle-end compiler optimizations.
  • To explore whether automated synthesis via superoptimization can discover novel, high-impact optimizations that are difficult or time-consuming to implement manually.
  • To evaluate the feasibility of using a single, generic superoptimizer across multiple compilers, including LLVM and Microsoft Visual C++.
  • To enable both automated optimization discovery and integration into production compilers through actionable, verified suggestions.
  • To investigate the potential of combining synthesis with proof-producing solvers for formally verified compilers in the future.

Proposed method

  • Uses a functional, control-flow-free intermediate representation (IR) closely modeled on LLVM IR, supporting 51 bitwidth-polymorphic integer instructions.
  • Employs SAT/SMT solvers to perform equivalence checking between original and synthesized code sequences, ensuring correctness.
  • Applies a synthesis algorithm extended from Gulwani et al. (2011) to generate optimal instruction sequences, including constant folding and propagation.
  • Operates as an optimization pass in LLVM, enabling cascading benefits from constant propagation and dead code elimination.
  • Caches optimization results to reduce compilation overhead in subsequent builds, achieving near-constant-time performance after warm-up.
  • Translates IR from other compilers (e.g., MSVC) into Souper’s IR to enable cross-compiler optimization discovery.

Experimental results

Research questions

  • RQ1Can a synthesizing superoptimizer automatically discover novel, correct, and beneficial compiler optimizations that are not expressible in standard compiler passes?
  • RQ2To what extent can a superoptimizer based on SAT/SMT solving and program synthesis outperform traditional hand-coded optimizations in real-world compilers?
  • RQ3Can the same superoptimizer framework be effectively applied across different compiler infrastructures, such as LLVM and Microsoft Visual C++?
  • RQ4How does the performance and code size impact of automated superoptimization compare to traditional compilation, especially when applied to large binaries like Clang?
  • RQ5What is the potential for integrating synthesized optimizations into formally verified compilers using proof-producing solvers?

Key findings

  • Souper discovered approximately 7,900 distinct optimizations when compiling LLVM itself, applying them over 85,000 times.
  • A Clang-3.9 binary compiled with Souper was 3 MB (4.4%) smaller than the same binary compiled with standard LLVM optimizations.
  • Despite a 2% performance regression in the optimized binary, the reduction in code size demonstrates significant practical benefit.
  • Initial compilation with Souper is 5× to 25× slower, but with a warm cache, compilation time is nearly identical to standard LLVM compilation (9 minutes vs. 8 minutes).
  • Several optimizations suggested by Souper were implemented by hand in both LLVM and Microsoft Visual C++ compilers, confirming their practical value.
  • Souper’s IR was successfully mapped to Microsoft Visual C++’s IR, enabling optimization discovery in a non-LLVM compiler, demonstrating cross-compiler applicability.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.