Yul Optimizer: reduce switches with const arguments

This commit is contained in:
Mathias Baumann
2019-02-28 15:43:10 +01:00
parent e9543d83c7
commit c686a65876
8 changed files with 118 additions and 1 deletions
@@ -0,0 +1,13 @@
{
mstore(f(1), 0)
function f(x) -> y {
switch x
case 0 { y := 8 }
case 1 { y := 9 }
}
}
// ----
// fullSuite
// {
// mstore(9, 0)
// }
@@ -0,0 +1,14 @@
{
mstore(f(3), 0)
function f(x) -> y {
switch x
case 0 { y := 8 }
case 1 { y := 9 }
default { y := 10 }
}
}
// ----
// fullSuite
// {
// mstore(10, 0)
// }
@@ -0,0 +1,14 @@
{
let y := 200
switch 1
case 0 { y := 8 }
case 1 { y := 9 }
}
// ----
// structuralSimplifier
// {
// let y := 200
// {
// y := 9
// }
// }
@@ -0,0 +1,15 @@
{
let y := 200
switch 3
case 0 { y := 8 }
case 1 { y := 9 }
default { y := 10 }
}
// ----
// structuralSimplifier
// {
// let y := 200
// {
// y := 10
// }
// }
@@ -0,0 +1,11 @@
{
let y := 200
switch 3
case 0 { y := 8 }
case 1 { y := 9 }
}
// ----
// structuralSimplifier
// {
// let y := 200
// }