Term Rewriting Systems (TRS) are used in compilers to simplify and prove expressions. State-of-the-art TRSs in compilers use a greedy algorithm that applies a set of rewriting rules in a predefined order (where some of the rules are not axiomatic). This leads to a loss in the ability to simplify certain expressions. E-graphs and equality saturation sidestep this issue by representing the different equivalent expressions in a compact manner from which the optimal expression can be extracted. While an e-graph-based TRS can be more powerful than a TRS that uses a greedy algorithm, it is slower because expressions may have a large or sometimes infinite number of equivalent expressions. Accelerating e-graph construction is crucial for making the use of e-graphs practical in compilers. In this paper, we present Caviar, an e-graph-based TRS for proving expressions within compilers. Caviar is a fast (20x faster than base e-graph TRS) and flexible (completely parameterized) TRS that that relies on three novel techniques: 1) a technique that stops e-graphs from growing when the goal is reached, called Iteration Level Check; 2) a mechanism that balances exploration and exploitation in the equality saturation algorithm, called Pulsing Caviar; 3) a technique to stop e-graph construction before reaching saturation when a non-provable pattern is detected, called Non-Provable Patterns Detection (NPPD). We evaluate caviar on Halide, an optimizing compiler that relies on a greedy-algorithm-based TRS to simplify and prove its expressions. The proposed techniques allow Caviar to accelerate e-graph expansion by 20x for the task of proving expressions. They also allow Caviar to prove 51% of the expressions that Halide's TRS cannot prove while being only 0.68x slower.
翻译:编译者使用电子绘图和平等饱和系统来简化和证明表达式。 编译者使用最先进的 TRS 来简化和证明表达式。 编译者使用最先进的 TRS 来使用一种贪婪的算法, 使用一套预定义的重写规则( 有些规则不合乎逻辑 ) 。 这导致某些表达式的简化能力丧失。 e- graphs 和平等饱和度可以代表不同的等同表达式, 从而从中解析最佳表达式。 以电子图表为基础的 TRS 系统比使用贪婪算法的 TRS 更强大。 由于表达方式可能具有大量或有时无限的等同表达式数量, 速度慢一些。 加速电子绘图构造对于在编译者中实际使用e- graphar 来说至关重要 。 在编译者中显示一个基于eviar的 TRS 表达式快速( 20x 速度比基于 e- demogradeal TRS 的表达式要快得多 ) 和灵活( 完全参数化) TRS 任务基于三种新技术 :1), 在达到S- regial- registring 之前, 上显示显示到递化到递缩缩缩缩缩缩缩算技术时,, 显示到技术, 伸缩算算法到 伸缩缩算法到 伸缩缩缩缩算到 。