arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2603.18477cs.PL
收藏

利用大型语言模型进行通用窥视优化

Leveraging Large Language Models for Generalizing Peephole Optimizations

University of Waterloo(滑铁卢大学)

Chunhao Liao, Hongxu Xu, Xintong Zhou, Zhenyang Xu, Chengnian Sun

AI总结:

本文提出LPG框架,利用大型语言模型进行窥视优化泛化,通过闭环工作流整合符号常量泛化、结构泛化、约束放松和位宽/精度泛化,提升优化规则的正确性和通用性。

摘要:

窥视优化是现代优化编译器的核心组成部分。它将特定指令重写为语义等价但更高效的格式。在实践中,创建新的窥视优化通常从具体优化实例开始,需要将其提升为更通用的重写规则,以匹配更广泛的操作数模式。这个泛化步骤对优化效果至关重要,但也很困难:产生既正确又足够通用的规则通常需要大量的手动工作和领域专业知识。现有方法如Hydra试图通过程序合成自动化此任务,但其泛化能力常受限于搜索空间爆炸、欠泛化和对多样化指令域的支持有限。我们提出LPG,即大型语言模型辅助的窥视优化泛化框架,利用大型语言模型(LLMs)进行窥视优化泛化。LPG的设计灵感来源于观察到LLMs在语义抽象和探索性推理方面有效,而形式分析是确保生成规则正确和有利的必要条件。基于这一观察,LPG采用闭环工作流,整合LLM驱动的符号常量泛化、结构泛化、约束放松、位宽/精度泛化以及来自语法验证、语义验证和盈利能力检查的反馈。我们评估LPG在真实世界窥视优化问题上的表现,这些问题来自LLVM生态系统。总体而言,LPG成功泛化了102个优化中的90个。在专注于整数的子集上,与Hydra直接比较,LPG泛化了81个优化中的74个,而Hydra泛化了35个。

英文摘要:

Peephole optimizations are a core component of modern optimizing compilers. It rewrites specific instruction into semantically equivalent but more efficient forms. In practice, creating a new peephole optimization often starts from a concrete optimization instance and requires lifting it into a more general rewrite rule that matches a wider range of instruction patterns. This generalization step is critical to optimization effectiveness, but it is also difficult: producing rules that are both correct and sufficiently general typically demands substantial manual effort and domain expertise. Existing approaches such as Hydra attempt to automate this task with program synthesis, but their generalization capability is often limited by search-space explosion, under-generalization, and restricted support for diverse instruction domains. We present LPG, large language model aided peephole optimization generalization, a framework that uses large language models (LLMs) to generalize peephole optimizations. The design of LPG is motivated by the observation that LLMs are effective at semantic abstraction and exploratory reasoning, while formal analyses are necessary to ensure that generated rules are sound and profitable. Based on this observation, LPG adopts a closed-loop workflow that integrates LLM-driven symbolic constant generalization, structural generalization, constraint relaxation, and bitwidth/precision generalization with feedback from syntactic validation, semantic verification, and profitability checking. We evaluate LPG on real-world peephole optimization issues drawn from the LLVM ecosystem. Overall, LPG successfully generalizes 90 out of 102 optimizations. On the integer-focused subset that is directly comparable to Hydra, LPG generalizes 74 out of 81 optimizations, whereas Hydra generalizes 35.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑