一句话:结合大语言模型与形式化验证,闭环自动发现 LLVM 中遗漏的窥孔优化。
窥孔优化对代码大小和性能至关重要,但指令集复杂,传统方法难扩展或限制多。LPO 的核心洞察是 LLM 擅长创造性探索却易产生幻觉,而形式验证能提供严格保证却难以发现新优化。该框架将两者结合成闭环反馈:LLM 生成候选窥孔优化,形式验证器验证其正确性,反馈再引导后续搜索。作者在 LLVM 生态中评估,LPO 在 25 个已知遗漏优化中识别出 22 个,优于 Souper 的 15 个和 Minotaur 的 3 个;在 11 个月开发与间歇测试中发现 62 个遗漏窥孔优化,其中 28 个被确认,另有 13 个已在 LLVM 中修复。结果表明该方法能持续发现新优化,并随 LLM 推理能力提升而受益。
Peephole optimization is an essential class of compiler optimizations that targets small, inefficient instruction sequences within programs. By replacing such suboptimal instructions with refined and more optimal sequences, these optimizations not only directly optimize code size and performance, but also enable more transformations in the subsequent optimization pipeline. Despite their importance, discovering new and effective peephole optimizations remains challenging due to the complexity and breadth of instruction sets. Prior approaches either lack scalability or have significant restrictions on the peephole optimizations that they can find. This paper introduces LPO, a novel automated framework to discover missed peephole optimizations. Our key insight is that, Large Language Models (LLMs) are effective at creative exploration but susceptible to hallucinations; conversely, formal verification techniques provide rigorous guarantees but struggle with creative discovery. By synergistically combining the strengths of LLMs and formal verifiers in a closed-loop feedback mechanism, LPO can effectively discover verified peephole optimizations that were previously missed. We comprehensively evaluated LPO within LLVM ecosystems. Our evaluation shows that LPO can successfully identify up to 22 out of 25 previously reported missed optimizations in LLVM. In contrast, the recently proposed superoptimizers for LLVM, Souper and Minotaur detected 15 and 3 of them, respectively. More importantly, within eleven months of development and intermittent testing, LPO found 62 missed peephole optimizations, of which 28 were confirmed and an additional 13 had already been fixed in LLVM. These results demonstrate LPO's strong potential to continuously uncover new optimizations as LLMs' reasoning improves.
DOI 原文 · arXiv · PDF(开放获取) · DBLP
@inproceedings{XuX0ZS26,
title = {LPO: Discovering Missed Peephole Optimizations with Large Language Models},
author = {Zhenyang Xu and Hongxu Xu and Yongqiang Tian and Xintong Zhou and Chengnian Sun},
booktitle = {ASPLOS},
year = {2026},
doi = {10.1145/3779212.3790184}
}