TL;DR
IntOpt is a novel, intent-driven intermediate representation (IR) optimizer that leverages Large Language Models (LLMs) to solve the long-standing "pass coordination problem" in modern compilers. By decoupling high-level optimization strategy (intent) from low-level code transformation across three structured stages, IntOpt achieves a 2.660× average speedup and 90.5% verified correctness, frequently outperforming LLVM’s highest optimization level (-O3).
What Problem Does This Paper Address?
Traditional compilers (like LLVM or GCC) optimize code by executing a fixed sequence of modular "passes" (e.g., loop unrolling, constant propagation). While great for software engineering, this pass-by-pass paradigm suffers from a fundamental flaw: the pass coordination problem. An early pass might make a change that is locally beneficial but inadvertently blocks a much more powerful optimization later in the pipeline.
Recent attempts to use LLMs for compiler optimization bypass this sequence by treating optimization as an end-to-end translation task (unoptimized IR $\rightarrow$ optimized IR). However, these methods hide the optimization strategy inside a black box. The LLM is forced to simultaneously figure out the high-level strategy and generate precise low-level code, which often leads to subtle semantic bugs and inconsistent performance.
Methods
IntOpt introduces a three-stage pipeline that mirrors how expert human compiler engineers operate:
- Intent Formulation: A specialized, fine-tuned 13B LLM (LLM Compiler FTD) analyzes the unoptimized IR and proposes an initial optimization strategy in natural language (e.g., "Apply loop interchange"). This bounds the action space and focuses the model purely on strategy.
- Intent Refinement: To ground this strategy in reality, IntOpt uses an automated Compiler Knowledge Base to determine which analytical passes (like Loop Analysis) are required to validate the strategy. It runs these analyses via the LLVM compiler and feeds the textual results to GPT-5 to refine the plan (e.g., adjusting vectorization width based on actual hardware support).
- Intent Realization: Finally, GPT-5 takes the refined strategy, the analysis constraints, and the original IR to generate the final, optimized IR.
Datasets
The authors utilized IR-OptSet, a dataset specifically designed to trigger representative optimization transformations in compilers.
- Training & Validation: 4,000 programs (
INTtrain) and 500 programs (INTval) were used to distill optimization intents and fine-tune the 13B model for the Intent Formulation stage. - Evaluation: A separate test set of 200 programs (
INTtest) was curated and filtered to ensure compatibility with formal verification tools and differential testing.
Key Insights and Ideas
- Decoupling Strategy from Execution: Separating what to do (intent) from how to rewrite the code drastically reduces the cognitive load on the LLM, leading to fewer hallucinations and more reliable code generation.
- Algorithmic vs. Syntactic Optimization: Traditional compilers look for rigid syntactic patterns. IntOpt can recognize high-level algorithmic intent. For example, it can recognize an iterative loop simulating a math problem and replace it entirely with an $O(1)$ closed-form equation, achieving massive performance leaps.
- Grounding LLMs with Compiler Analysis: Pure LLMs struggle with precise hardware and data-flow constraints. By explicitly feeding LLVM's analytical pass data back into the LLM during the refinement stage, the model makes hardware-aware, semantically sound choices.
Key Results
IntOpt was evaluated against state-of-the-art LLMs (GPT-5, Claude Haiku 4.5, DeepSeek-V3.2), specialized compiler models, and traditional LLVM -O3.
- Superior Correctness: Using a rigorous two-stage verification process (Alive2 formal verification + LibFuzzer differential testing), IntOpt achieved 90.5% verified correctness, outperforming other LLM baselines by 7.0% to 31.5%.
- Massive Speedups: IntOpt achieved an average 2.660× speedup over unoptimized IR, significantly outperforming the best end-to-end LLM baseline (GPT-5 at 1.057×).
- Beating LLVM -O3: IntOpt matched LLVM -O3 on 105 programs and outperformed it on 37 programs, achieving maximum speedups of up to 272.60× over -O3 by discovering global optimizations that traditional compilers miss.
Limitations and Future Work
- Computational Overhead: Relying on large commercial models like GPT-5 for the refinement and realization steps introduces significant latency and cost compared to traditional, near-instantaneous compiler passes.
- Context Window Constraints: The current framework caps input programs at 5,000 tokens, meaning it cannot yet optimize massive, multi-file production codebases without modular breakdown.
- Residual Errors: While 90.5% correctness is a major leap for LLM-based compilation, compilers demand 100% reliability. Tightening the integration between LLM generation and formal compiler validation remains an open challenge.
Summary updated