Towards -O<sub>mL</sub>: A Deep Learning Based Approach for Outperforming Compiler Defaults
Compilers offer default optimization levels (e.g., -O<inf xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">z</inf>, -O<inf xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">3</inf>) to generate high performance code based on developer goals such as size, speed, or energy efficiency. As prior work has shown, however, these default levels often generate code that leaves substantial room for improvement. While per-application tuning of compiler heuristics can yield performance benefits, it is time-consuming and lacks generality. A preferred solution is one where a single deep learning model can (i) surpass performance of compiler defaults and (ii) is sufficiently practical to be integrated into the compiler as its own option, e.g., -O<inf xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">mL</inf>.In this work, we first train such a deep learning model for code size reduction (-O<inf xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">zmL</inf>). Our reinforcement learning (RL) based approach achieves an average reduction in code size of 1.40% over GCC 13’s -O<inf xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">z</inf> and yields 1.37% better byte reduction as compared to state-of-the-art efforts. Across a large, diverse set of functions from standard benchmarks, this model optimizes 36.7% of the functions achieving an average 8.45% code size reduction on top of -O<inf xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">z</inf> for those functions. As expected with any model, however, there are still some functions whose performance degrades when compared to -O<inf xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">z</inf>. We therefore propose a classifier to be used in tandem with the model to reduce such performance regressions, reducing them by 99%. Results demonstrate the viability of a practical and learning-based -O<inf xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">mL</inf> optimization level in production compilers.
Authors
- Ulrich Drepper (ORCID: https://orcid.org/0009-0004-5120-7869)
- Hafsah Shahzad (ORCID: https://orcid.org/0000-0003-1181-5603)
- Martin Herbordt (ORCID: https://orcid.org/0000-0002-3443-9113)
- Ahmed Sanaullah (ORCID: https://orcid.org/0000-0002-7169-480X)
- S. Arora
Institutions
- Boston University (US)
- Red Hat (United States) (US)
Publication Details
- Published
- 2025-09-15
- DOI
- https://doi.org/10.1109/hpec67600.2025.11196093
- Primary Topic
- Software System Performance and Reliability
- Type
- article
- Field-Weighted Citation Impact
- 0.00