Skip to content

Commit 7c3bff0

Browse files
committed
Add tests
1 parent 30f2018 commit 7c3bff0

11 files changed

Lines changed: 256 additions & 0 deletions

test/libyul/YulOptimizerTestCommon.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,16 @@ YulOptimizerTestCommon::YulOptimizerTestCommon(std::shared_ptr<Object const> _ob
311311
ExpressionJoiner::run(*m_context, block);
312312
return block;
313313
}},
314+
{"unusedStoreEliminatorNoSsaTransform", [&]() {
315+
auto block = disambiguate();
316+
updateContext(block);
317+
ForLoopInitRewriter::run(*m_context, block);
318+
ExpressionSplitter::run(*m_context, block);
319+
UnusedStoreEliminator::run(*m_context, block);
320+
SSAReverser::run(*m_context, block);
321+
ExpressionJoiner::run(*m_context, block);
322+
return block;
323+
}},
314324
{"equalStoreEliminator", [&]() {
315325
auto block = disambiguate();
316326
updateContext(block);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
let x := calldataload(0)
3+
x := calldataload(32)
4+
let a := add(x, 32)
5+
let b := x
6+
let outLen := 32
7+
mstore(a, 0xAA)
8+
return(b, outLen)
9+
}
10+
// ----
11+
// step: unusedStoreEliminatorNoSsaTransform
12+
//
13+
// {
14+
// {
15+
// let x := calldataload(0)
16+
// x := calldataload(32)
17+
// let a := add(x, 32)
18+
// let b := x
19+
// let outLen := 32
20+
// mstore(a, 0xAA)
21+
// return(b, outLen)
22+
// }
23+
// }
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
function f(arg)
3+
{
4+
let a := add(arg, 1)
5+
let b := arg
6+
let outLen := 32
7+
mstore(a, 0xAA)
8+
return(b, outLen)
9+
}
10+
}
11+
12+
// ----
13+
// step: unusedStoreEliminatorNoSsaTransform
14+
//
15+
// {
16+
// { }
17+
// function f(arg)
18+
// {
19+
// let a := add(arg, 1)
20+
// let b := arg
21+
// let outLen := 32
22+
// mstore(a, 0xAA)
23+
// return(b, outLen)
24+
// }
25+
// }
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
function f(arg)
3+
{
4+
let a := add(arg, 32)
5+
let b := arg
6+
let outLen := 32
7+
mstore(a, 0xAA)
8+
return(b, outLen)
9+
}
10+
}
11+
12+
// ----
13+
// step: unusedStoreEliminatorNoSsaTransform
14+
//
15+
// {
16+
// { }
17+
// function f(arg)
18+
// {
19+
// let a := add(arg, 32)
20+
// let b := arg
21+
// let outLen := 32
22+
// let _2 := 0xAA
23+
// return(b, outLen)
24+
// }
25+
// }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
function f(arg)
3+
{
4+
let b := arg
5+
arg:= add(arg, 1)
6+
let outLen := 32
7+
mstore(arg, 0xAA)
8+
return(b, outLen)
9+
}
10+
}
11+
12+
// ----
13+
// step: unusedStoreEliminatorNoSsaTransform
14+
//
15+
// {
16+
// { }
17+
// function f(arg)
18+
// {
19+
// let b := arg
20+
// arg := add(arg, 1)
21+
// let outLen := 32
22+
// mstore(arg, 0xAA)
23+
// return(b, outLen)
24+
// }
25+
// }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
function f(arg)
3+
{
4+
let b := arg
5+
arg := add(arg, 32)
6+
let outLen := 32
7+
mstore(arg, 0xAA)
8+
return(b, outLen)
9+
}
10+
}
11+
12+
// ----
13+
// step: unusedStoreEliminatorNoSsaTransform
14+
//
15+
// {
16+
// { }
17+
// function f(arg)
18+
// {
19+
// let b := arg
20+
// arg := add(arg, 32)
21+
// let outLen := 32
22+
// mstore(arg, 0xAA)
23+
// return(b, outLen)
24+
// }
25+
// }
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
let x := calldataload(4)
3+
let x_5 := x
4+
let a := add(x_5, 32)
5+
x := add(x_5, 32)
6+
let b := x
7+
let outLen := 32
8+
mstore(a, 0xAA)
9+
return(b, outLen)
10+
}
11+
12+
// ----
13+
// step: unusedStoreEliminatorNoSsaTransform
14+
//
15+
// {
16+
// {
17+
// let x := calldataload(4)
18+
// let x_5 := x
19+
// let a := add(x_5, 32)
20+
// x := add(x_5, 32)
21+
// let b := x
22+
// let outLen := 32
23+
// mstore(a, 0xAA)
24+
// return(b, outLen)
25+
// }
26+
// }
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
function g() -> r1, r2
3+
{
4+
r1 := calldataload(0)
5+
r2 := calldataload(32)
6+
}
7+
let a, b := g()
8+
let c := add(a, 32)
9+
mstore(c, 0xAA)
10+
return(a, b)
11+
}
12+
// ----
13+
// step: unusedStoreEliminatorNoSsaTransform
14+
//
15+
// {
16+
// {
17+
// let a, b := g()
18+
// let c := add(a, 32)
19+
// mstore(c, 0xAA)
20+
// return(a, b)
21+
// }
22+
// function g() -> r1, r2
23+
// {
24+
// r1 := calldataload(0)
25+
// r2 := calldataload(32)
26+
// }
27+
// }
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
let x := calldataload(0)
3+
let y := add(x, 32)
4+
let a := add(y, 32)
5+
let b := x
6+
let outLen := 32
7+
mstore(a, 0xAA)
8+
return(b, outLen)
9+
}
10+
// ----
11+
// step: unusedStoreEliminatorNoSsaTransform
12+
//
13+
// {
14+
// {
15+
// let x := calldataload(0)
16+
// let y := add(x, 32)
17+
// let a := add(y, 32)
18+
// let b := x
19+
// let outLen := 32
20+
// let _4 := 0xAA
21+
// return(b, outLen)
22+
// }
23+
// }
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
function f(arg)
3+
{
4+
let x := arg
5+
x := calldataload(32)
6+
sstore(x, 0xAA)
7+
sstore(arg, 0xBB)
8+
}
9+
}
10+
// ----
11+
// step: unusedStoreEliminatorNoSsaTransform
12+
//
13+
// {
14+
// { }
15+
// function f(arg)
16+
// {
17+
// let x := arg
18+
// x := calldataload(32)
19+
// sstore(x, 0xAA)
20+
// sstore(arg, 0xBB)
21+
// }
22+
// }

0 commit comments

Comments
 (0)