Machine Learning Techniques for Compiler Optimization

Summary

Machine learning has emerged as a transformative approach to compiler optimisation by automating decisions that were traditionally based on heuristics or exhaustive search. At its core, this research area addresses the extraction of meaningful program features—ranging from static code metrics to dynamic performance counters—and the mapping of those features to optimisation actions such as pass ordering, parameter tuning or source‐level transformation. Techniques span supervised and reinforcement learning, neural representation learning and ensemble methods. Supervised models can predict effective compiler flags or sequences given a program’s feature vector, while reinforcement learning agents explore the space of pass orderings by receiving feedback on runtime or code-size rewards. Neural architectures, including sequence-to-sequence models and graph neural networks, have been applied both to source code and to compiler intermediate representations (IR), learning continuous embeddings that capture syntactic and semantic information. Across diverse hardware platforms—from embedded systems to high-performance clusters—these approaches have demonstrated improvements in execution time, energy consumption and code size, often reducing human effort and accelerating the optimisation pipeline.

Research from Nature Portfolio

No recent Nature Portfolio content available.

Research from all publishers

Recent studies have introduced neural approaches to source-level optimisation. The Supersonic framework employs a sequence-to-sequence model trained on pairs of C/C++ programs to generate minimal diffs that enhance performance while preserving semantics. Benchmarking against large language models demonstrates heightened efficiency with a model size many times smaller than leading baselines. Another approach addresses pass selection by modelling dependencies among compiler passes. By clustering passes into sub-sequences, this method translates exhaustive search into selecting optimal combinations of sub-sequences, yielding gains of over 20% in runtime performance and substantial code-size reduction on LLVM backends. Work on representation learning has produced IR2VEC, which encodes compiler intermediate representations into distributed embeddings that capture both syntactic structure and control-flow information. These embeddings, when used in downstream tasks such as heterogeneous device mapping and thread coarsening, enable compact models to match or surpass state-of-the-art optimisation across diverse benchmark suites.

Machine Learning Techniques for Compiler Optimization publication trend

The graph below shows the total number of articles in machine learning techniques for compiler optimization across all publications each year (not limited to Nature Index journals).

Technical terms

Sequence-to-sequence model: A neural network architecture that transforms an input sequence into an output sequence, often used for code-to-code translation.

Intermediate Representation (IR): A language- and machine-independent code abstraction used by compilers to apply optimisation passes.

Compiler pass: A discrete transformation or analysis stage in a compiler pipeline that modifies or evaluates code.

Embedding: A technique that maps discrete entities such as code tokens or IR elements to continuous vectors reflecting semantic relationships.

Program feature: Quantitative or categorical attributes extracted from source code or execution behaviour, used as inputs for machine learning models.

References

  1. Supersonic: Learning to Generate Source Code Optimizations in C/C++. IEEE Transactions on Software Engineering (2024).
  2. IR2VEC. ACM Transactions on Architecture and Code Optimization (2020).
  3. Efficient compiler optimization by modeling passes dependence. CCF Transactions on High Performance Computing (2024).

About these summaries

This Nature Research Intelligence Topic summary is created with the cited references and a large language model. We take care to ground generated text with facts, and have systems in place to gain human feedback on the overall quality of the process in line with our AI principles. We strive to create accurate and useful summaries for people unfamiliar with the research topic and that supports this goal. These pages are a beta release and will be updated as we learn how best to help people gain value from a research topic summary.

Nature Strategy Reports
Turn complex research questions into confident strategic decisions 

When you're under pressure to set direction, justify investment, or understand your competitive position, you need more than raw data — you need trusted insights you can act on.

  • Benchmark your performance against global peers using robust, methodologically sound analysis.

  • Combine quantitative metrics with qualitative expert insight to uncover strengths, gaps and emerging opportunities.

  • Gain tailored, decision-ready recommendations aligned to your strategic priorities.

Talk to us to learn more about our data dashboards and bespoke strategy reports.

Nature Masterclasses
Grow research skills, confidence and careers with training built for every stage of the research lifecycle.

Developed with Nature Portfolio journal Editors and internationally renowned experts. Discover three ways to learn:

  • Self-paced, online courses in convenient bite-sized units, covering key skills across scientific writing, publishing, grant writing, data analysis, and more.

  • Expert trainer-led workshops with hands-on exercises and real-time feedback across core research skills, delivered via interactive group sessions.

  • Editor-led workshops combining core principles in writing and publishing, personalised 1:1 feedback from Nature Portfolio Editors and hands-on exercises.

Explore course catalogues and workshop agendas, enquire about the options or request institutional pricing.