超越阶段排序问题:寻找关于优化阶段的全局最优代码
Beyond the Phase Ordering Problem: Finding the Globally Optimal Code w.r.t. Optimization Phases
AI总结:
本文提出关于优化阶段的语义等价概念和迭代双向优化技术,通过结合正向与逆向优化阶段,超越传统阶段排序问题的穷举搜索,在真实大型程序中找到全局最优代码并提升编译器优化效果。
摘要:
在本文中,我们提出了一个名为“关于优化阶段的语义等价(SEP)”的新概念,它定义了编译器使用一组优化阶段时认为与输入程序语义等价的程序集合。我们从理论和实验两方面表明,解决阶段排序问题并不一定能在编译器认为与输入语义等价的所有程序中产生最高效的代码,下文将这种代码称为关于优化阶段的全局最优代码。为了找到关于优化阶段的全局最优代码,我们提出了一个概念框架,利用现有优化阶段的逆向过程。在理论上,我们证明了该框架能够为任意程序找到全局最优代码。我们将该框架实现为一种称为“迭代双向优化(IBO)”的技术,它同时执行正向优化和逆向优化,分别用于提高和降低生成代码的效率。我们在从高度成熟且有影响力的程序(例如 Linux 内核、OpenSSL、Z3)中随机提取的 C/C++ 文件上评估了 IBO。结果表明,无论以代码大小还是运行时性能来衡量,IBO 经常生成比穷举搜索更高效的代码,而穷举搜索是阶段排序问题的解。我们还发现,仅通过引入 IBO 的逆向优化阶段,就可以显著提升最先进编译器(例如 GCC/LLVM)的优化效果。
英文摘要:
In this paper, we propose a new concept called \textit{semantically equivalence} \wrt \textit{optimization phases} \textit{(\sep)}, which defines the set of programs a compiler considers semantically equivalent to the input using a set of optimization phases. We show both theoretically and empirically that solving the phase ordering problem does not necessarily result in the most efficient code among all programs that a compiler deems semantically equivalent to the input, hereinafter referred to as the global optimal code \wrt optimization phases. To find the global optimal code \wrt optimization phases, we present a conceptual framework, leveraging the reverse of existing optimization phases. In theory, we prove that the framework is capable of finding the global optimal code for any program. We realize this framework into a technique, called \textit{iterative bi-directional optimization (\tool)}, which performs both the normal and reverse optimizations to increase and decrease the efficiency of the generated code, respectively. We evaluate \tool on C/C++ files randomly extracted from highly mature and influential programs (\eg, Linux kernel, OpenSSL, Z3). Results show that \tool frequently generates more efficient code -- measured by either code size or runtime performance -- than exhaustive search, which is the solution to the phase ordering problem. We also find by simply incorporating \tool's reverse optimization phases, the effectiveness of the optimization of state-of-the-art compilers (\eg, GCC/LLVM) can be significantly improved.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。