Table of Contents
Fetching ...

Beyond Pass-by-Pass Optimization: Intent-Driven IR Optimization with Large Language Models

Lei Qiu, Zi Yang, Fang Lyu, Ming Zhong, Huimin Cui, Xiaobing Feng

TL;DR

IntOpt tackles the pass-by-pass coordination problem in IR optimization by making optimization intent explicit and separating it from low-level analysis and transformations. Through a three-stage pipeline—intent formulation, refinement, and realization—IntOpt leverages an optimization-specialized LLM, a compiler knowledge base, and grounded analyses to produce globally coordinated IR optimizations. Empirical results on 200 LLVM IR programs show a $90.5\%$ verified correctness rate and a $2.660\times$ average speedup, outperforming end-to-end LLM-based IR optimizers and surpassing LLVM -O3 on select benchmarks with up to $272.60\times$ speedups. The work demonstrates that explicit intent, combined with compiler knowledge and analysis grounding, yields more reliable and powerful optimizations than traditional pass pipelines or black-box endpoints, suggesting a promising direction for trustworthy AI-assisted compiler optimization.

Abstract

Modern compilers optimize programs through a sequence of modular passes over intermediate representations (IR). While this pass-by-pass paradigm offers engineering benefits, it suffers from a pass coordination problem: locally beneficial transformations may block more profitable optimizations in later stages. This limitation stems from the lack of an explicit notion of optimization intent, defined as a holistic strategy for coordinating multiple transformations toward a global performance objective. Recent LLM-based approaches formulate IR optimization as an end-to-end generation task, thereby avoiding the traditional pass-by-pass structure. However, optimization intent remains implicit in these methods, forcing models to jointly infer optimization strategy and generate low-level transformations, which limits both correctness and performance. We propose IntOpt, the first intent-driven IR optimizer that explicitly separates high-level optimization intent from low-level analysis and transformation. IntOpt organizes IR optimization into three stages: intent formulation, intent refinement, and intent realization, enabling globally coordinated transformations. Experiments show that IntOpt achieves 90.5% verified correctness and 2.660x average speedup on 200-program test set, outperforming state-of-the-art LLM-based optimizers in both correctness and performance, and surpassing modern compiler with the -O3 option on 37 benchmarks with speedups of up to 272.60x.

Beyond Pass-by-Pass Optimization: Intent-Driven IR Optimization with Large Language Models

TL;DR

IntOpt tackles the pass-by-pass coordination problem in IR optimization by making optimization intent explicit and separating it from low-level analysis and transformations. Through a three-stage pipeline—intent formulation, refinement, and realization—IntOpt leverages an optimization-specialized LLM, a compiler knowledge base, and grounded analyses to produce globally coordinated IR optimizations. Empirical results on 200 LLVM IR programs show a verified correctness rate and a average speedup, outperforming end-to-end LLM-based IR optimizers and surpassing LLVM -O3 on select benchmarks with up to speedups. The work demonstrates that explicit intent, combined with compiler knowledge and analysis grounding, yields more reliable and powerful optimizations than traditional pass pipelines or black-box endpoints, suggesting a promising direction for trustworthy AI-assisted compiler optimization.

Abstract

Modern compilers optimize programs through a sequence of modular passes over intermediate representations (IR). While this pass-by-pass paradigm offers engineering benefits, it suffers from a pass coordination problem: locally beneficial transformations may block more profitable optimizations in later stages. This limitation stems from the lack of an explicit notion of optimization intent, defined as a holistic strategy for coordinating multiple transformations toward a global performance objective. Recent LLM-based approaches formulate IR optimization as an end-to-end generation task, thereby avoiding the traditional pass-by-pass structure. However, optimization intent remains implicit in these methods, forcing models to jointly infer optimization strategy and generate low-level transformations, which limits both correctness and performance. We propose IntOpt, the first intent-driven IR optimizer that explicitly separates high-level optimization intent from low-level analysis and transformation. IntOpt organizes IR optimization into three stages: intent formulation, intent refinement, and intent realization, enabling globally coordinated transformations. Experiments show that IntOpt achieves 90.5% verified correctness and 2.660x average speedup on 200-program test set, outperforming state-of-the-art LLM-based optimizers in both correctness and performance, and surpassing modern compiler with the -O3 option on 37 benchmarks with speedups of up to 272.60x.
Paper Structure (37 sections, 9 equations, 6 figures, 4 tables)

This paper contains 37 sections, 9 equations, 6 figures, 4 tables.

Figures (6)

  • Figure 1: Comparison between existing IR optimization approaches and our IntOpt.
  • Figure 2: Overview of IntOpt.
  • Figure 3: Per-program speedup comparison between IntOpt and representative end-to-end LLM-based IR optimizers. Speedup differences within $\pm$2% are considered equal to account for runtime variability.
  • Figure 4: Performance comparison between IntOpt and LLVM -O3. Speedup is defined as $\text{RunTime}(\text{LLVM -O3}) / \text{RunTime}(\text{opt})$, with $[0.98,1.02]$ treated as equal. IntOpt matches LLVM -O3 on 105 programs and outperforms it on 37 (max $272.60\times$); among 58 underperforming cases, most are slight slowdowns (27 in $[0.90,0.98]$), and 19 are incorrect.
  • Figure 5: Case study illustrating how IntOpt explores optimization opportunities beyond the traditional pass-by-pass compiler paradigm.
  • ...and 1 more figures