Add structural simplifier as optimization step for Yul.

This commit is contained in:
Daniel Kirchner
2018-12-06 18:37:35 +01:00
parent 4b2a64306a
commit 1eb60cbb39
19 changed files with 292 additions and 15 deletions
@@ -0,0 +1,7 @@
{ let a := mload(0) if a {} }
// ----
// structuralSimplifier
// {
// let a := mload(0)
// pop(a)
// }
@@ -0,0 +1,6 @@
{ if mload(0) {} }
// ----
// structuralSimplifier
// {
// pop(mload(0))
// }
@@ -0,0 +1,10 @@
{
for { let a := 42 } 0 { a := a } {
let b := a
}
}
// ----
// structuralSimplifier
// {
// let a := 42
// }
@@ -0,0 +1,5 @@
{ if 0 { mstore(0, 0) } }
// ----
// structuralSimplifier
// {
// }
@@ -0,0 +1,6 @@
{ if 1 { mstore(0, 0) } }
// ----
// structuralSimplifier
// {
// mstore(0, 0)
// }
@@ -0,0 +1,6 @@
{ if 1 { if 1 { for { mstore(0, 0) } 0 {} { mstore(2, 3) } if 0 { mstore(1, 2) } } } }
// ----
// structuralSimplifier
// {
// mstore(0, 0)
// }
@@ -0,0 +1,11 @@
{
switch mload(0) default { mstore(1, 2) }
}
// ----
// structuralSimplifier
// {
// pop(mload(0))
// {
// mstore(1, 2)
// }
// }
@@ -0,0 +1,11 @@
{
switch 1 case 2 { mstore(0, 0) }
}
// ----
// structuralSimplifier
// {
// if eq(2, 1)
// {
// mstore(0, 0)
// }
// }