编译器漏掉的优化,LLM 能补上?SeGaBench 测出最强模型在 93% 用例上拿到性能提升,挺有意思。
SeGaBench 包含 100 个合成用例和 20 个真实源码用例,覆盖底层假设、数据结构不变式和高层语义提升。研究评估了五个大语言模型,每个用例取五次独立响应。最强模型在 94.8% 的响应中生成正确工件,83.3% 的响应实现至少 1.05 倍加速,在 93.3% 的用例上获得性能成功。结果表明 LLM 可作为推测性语义提议者,但生成工件仍需验证。
Can Large Language Models Recover Semantic Optimization Opportunities That Compilers Miss?
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.