Yul: Implements empty-var-decl-propagation

This commit is contained in:
Christian Parpart
2018-10-26 13:13:57 +02:00
committed by Christian Parpart
parent 41375b5d79
commit f08ab77249
12 changed files with 302 additions and 0 deletions
+6
View File
@@ -22,6 +22,7 @@
#include <test/Options.h>
#include <libyul/optimiser/BlockFlattener.h>
#include <libyul/optimiser/VarDeclPropagator.h>
#include <libyul/optimiser/Disambiguator.h>
#include <libyul/optimiser/CommonSubexpressionEliminator.h>
#include <libyul/optimiser/NameCollector.h>
@@ -102,6 +103,11 @@ bool YulOptimizerTest::run(ostream& _stream, string const& _linePrefix, bool con
disambiguate();
BlockFlattener{}(*m_ast);
}
else if (m_optimizerStep == "varDeclPropagator")
{
disambiguate();
VarDeclPropagator{}(*m_ast);
}
else if (m_optimizerStep == "commonSubexpressionEliminator")
{
disambiguate();
@@ -0,0 +1,17 @@
{
let a := 4
let x
if a {
x := 2
}
}
// ----
// varDeclPropagator
// {
// let a := 4
// let x
// if a
// {
// x := 2
// }
// }
@@ -0,0 +1,13 @@
{
function f() -> a, b, c {}
let x, y, z
z, x, y := f()
}
// ----
// varDeclPropagator
// {
// function f() -> a, b, c
// {
// }
// let z, x, y := f()
// }
@@ -0,0 +1,11 @@
{
let a
a := 4
a := 5
}
// ----
// varDeclPropagator
// {
// let a := 4
// a := 5
// }
@@ -0,0 +1,10 @@
{
let a, b
a := mload(0)
}
// ----
// varDeclPropagator
// {
// let b
// let a := mload(0)
// }
@@ -0,0 +1,9 @@
{
let f
f := mload(0)
}
// ----
// varDeclPropagator
// {
// let f := mload(0)
// }
@@ -0,0 +1,11 @@
{
let a, b
a := mload(0)
b := mload(1)
}
// ----
// varDeclPropagator
// {
// let a := mload(0)
// let b := mload(1)
// }
@@ -0,0 +1,12 @@
{
let b
let a := b
b := 1
}
// ----
// varDeclPropagator
// {
// let b
// let a := b
// b := 1
// }
@@ -0,0 +1,16 @@
{
function f(x) {}
let a
f(a)
a := 4
}
// ----
// varDeclPropagator
// {
// function f(x)
// {
// }
// let a
// f(a)
// a := 4
// }