#dsl #optimization #converting


Converting Souper optimizations into Peepmatic DSL

9 breaking releases

0.78.0 Oct 29, 2021
0.76.0 Aug 2, 2021
0.75.0 Jun 9, 2021
0.72.0 Mar 16, 2021

#1188 in Rust patterns

Apache-2.0 WITH LLVM-exception

615 lines


Converting Souper optimizations into Peepmatic DSL.

Conversion from Souper into Peepmatic is implemented with a straightforward, top-down recursive traversal of the optimization's left- and right-hand side expression DAGs. Most Souper instructions have a corresponding Peepmatic instruction. If we run into an instruction where that isn't the case, we skip that Souper optimization and move on to the next one.

Note that Souper fully supports DAGs, for example:

%0 = var
%1 = add 1, %0
%2 = add %1, %1       ;; Two edges to `%1` makes this a DAG.

On the other hand, Peepmatic only currently supports trees, so shared subexpressions are duplicated:

(iadd (iadd 1 $x)
      (iadd 1 $x))    ;; The shared subexpression is duplicated.

This does not affect correctness.