Merge pull request #5128 from ethereum/breakUnbreak

[Yul] Test case that shows that break / unbreak are more or less inverse
This commit is contained in:
chriseth 2018-11-09 16:07:20 +01:00 committed by GitHub
commit 9709dfe046
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 74 additions and 5 deletions

View File

@ -120,6 +120,19 @@ bool YulOptimizerTest::run(ostream& _stream, string const& _linePrefix, bool con
NameDispenser nameDispenser(*m_ast);
ExpressionSplitter{nameDispenser}(*m_ast);
}
else if (m_optimizerStep == "expressionJoiner")
{
disambiguate();
ExpressionJoiner::run(*m_ast);
}
else if (m_optimizerStep == "splitJoin")
{
disambiguate();
NameDispenser nameDispenser(*m_ast);
ExpressionSplitter{nameDispenser}(*m_ast);
ExpressionJoiner::run(*m_ast);
ExpressionJoiner::run(*m_ast);
}
else if (m_optimizerStep == "functionGrouper")
{
disambiguate();
@ -177,11 +190,6 @@ bool YulOptimizerTest::run(ostream& _stream, string const& _linePrefix, bool con
disambiguate();
UnusedPruner::runUntilStabilised(*m_ast);
}
else if (m_optimizerStep == "expressionJoiner")
{
disambiguate();
ExpressionJoiner::run(*m_ast);\
}
else if (m_optimizerStep == "ssaTransform")
{
disambiguate();

View File

@ -0,0 +1,26 @@
{
if mul(add(calldataload(0), 2), 3) {
for { let a := 2 } lt(a, mload(a)) { a := add(a, mul(a, 2)) } {
let b := mul(add(a, 2), 4)
sstore(b, mul(b, 2))
}
}
}
// ----
// splitJoin
// {
// if mul(add(calldataload(0), 2), 3)
// {
// for {
// let a := 2
// }
// lt(a, mload(a))
// {
// a := add(a, mul(a, 2))
// }
// {
// let b := mul(add(a, 2), 4)
// sstore(b, mul(b, 2))
// }
// }
// }

View File

@ -0,0 +1,30 @@
{
let x := f(0)
function f(y) -> r {
r := mload(mul(6, add(y, 0x20)))
}
for { let a := 2 } lt(a, mload(a)) { a := add(a, mul(a, 2)) } {
let b := mul(add(a, f(a)), 4)
sstore(b, mul(b, 2))
}
}
// ----
// splitJoin
// {
// let x := f(0)
// function f(y) -> r
// {
// r := mload(mul(6, add(y, 0x20)))
// }
// for {
// let a := 2
// }
// lt(a, mload(a))
// {
// a := add(a, mul(a, 2))
// }
// {
// let b := mul(add(a, f(a)), 4)
// sstore(b, mul(b, 2))
// }
// }

View File

@ -0,0 +1,5 @@
{}
// ----
// splitJoin
// {
// }