arXiv:2608.03983cs.PLcs.AI2026-08

大模型能补全编译器遗漏的语义优化,提升程序性能。

Can Large Language Models Recover Semantic Optimization Opportunities That Compilers Miss?

  • 用大模型从复杂C/C++代码中推测缺失的语义信息。
  • 在94.8%的案例中生成正确优化结果,83.3%实现至少1.05倍加速。
  • 适合编译器研发者与性能优化工程师参考使用。

优化编译器常因程序表示中缺少必要语义而错过有效变换。本文探究大语言模型(LLMs)能否从异构的C/C++上下文中恢复这些语义,并将其转化为可验证、符合契约的优化成果。为此,我们构建了SeGaBench——一个包含100个合成案例和20个真实源码案例的可执行基准测试集,涵盖底层假设、数据结构不变式及高层语义提升。每个案例均含隐藏语义、目标优化代码、正确性与语义验证器及可复现性能评估协议。我们对五种大模型进行评估,每案例生成五次独立响应。最强模型在94.8%的响应中生成正确优化产物,在83.3%案例中实现至少1.05倍速度提升,93.3%案例达到性能成功标准。然而,多数正确优化仅部分填补了目标性能差距。结果表明,大模型可作为编译器分析的补充,以推测性语义提案者角色发挥作用,前提是其输出需经过验证与评估。

原文摘要 · Abstract (English)

Optimizing compilers miss profitable transformations when their enabling semantics are absent from the analyzed program representation. We ask whether large language models (LLMs) can recover such semantics from heterogeneous C/C++ context and realize them as validated, contract-preserving artifacts. We introduce SeGaBench, an executable benchmark containing 100 synthetic and 20 source-backed cases spanning low-level assumptions, data-structure invariants, and high-level semantic lifting. Each case includes hidden enabling semantics, an oracle artifact, correctness and semantic validators, and a reproducible performance protocol. We evaluate five LLMs using five independent responses per case. The strongest model produces correct artifacts in 94.8% of responses, achieves at least 1.05x speedup in 83.3%, and obtains a performance success on 93.3% of cases. Nevertheless, correct artifacts often close only part of the oracle gap. These results show that LLMs can complement compiler analysis as speculative semantic proposers, provided that their artifacts are validated and evaluated.

大模型编译优化语义恢复性能提升

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。