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

E-Graphs作为持久化的编译器抽象

E-Graphs as a Persistent Compiler Abstraction

Ghent University(根特大学);University of Cambridge(剑桥大学);University College London(伦敦大学学院);University of Edinburgh(爱丁堡大学)

Jules Merckx, Alexandre Lopoukhine, Samuel Coward, Jianyi Cheng, Bjorn De Sutter, Tobias Grosser

AI总结:

本文提出了一种在编译器中间表示中原生表示e-graph的方法,通过引入eqsat方言,实现等价饱和在不同中间表示层次上的统一应用,提升编译器优化能力。

摘要:

近期的算法进展使等价饱和成为程序优化有吸引力的方法,因为它避免了相序问题。现有工作使用外部等价饱和库或深度绑定到特定应用的自定义实现。然而,这些工作只在抽象层次的单一层面应用等价饱和,或在代码被其他编译器传递转换时丢弃发现的等价关系。我们提出了一种替代方法,使编译器的中间表示原生地表示e-graph,从而促进应用维护e-graph状态的构造性编译器传递。我们基于Python的MLIR框架xDSL,引入了一个新的MLIR方言eqsat,该方言在MLIR代码中表示e-graph。我们展示了这种表示扩展了编译器中等价饱和的范围,允许将模式重写与其他编译器转换交织在一起。eqsat方言为编译器提供了一种统一的抽象,使编译器能够在同一MLIR流程中同时在各种中间表示层次上利用等价饱和。

英文摘要:

Recent algorithmic advances have made equality saturation an appealing technique for program optimization, avoiding the phase-ordering problem by separating the discovery of equivalent expressions from optimal expression selection. Existing work leveraging equality saturation in compilers uses either external equality saturation libraries or custom implementations that are coupled to the specific application. These approaches are inherently limited, as the first discards semantic equivalences when translating back from the external library, while the second restricts equality saturation to a single level of abstraction. We propose an alternative approach that represents an e-graph natively in code, facilitating the application of constructive compiler passes that maintain the e-graph state throughout the compilation flow. We present Tamagoyaki, an implementation of this approach in MLIR and demonstrate its versatility through partial re-implementations of two equality saturation applications. Our software case study improves performance by 1.18$\times$ on average, whilst our hardware case study reduces circuit delay by up to 11% over standard equality saturation. Building on reusable compiler infrastructure, our work expands the scope of equality saturation, making it persistent across and interleavable with other analyses and transformations.

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

↑