diff options
author | chriseth <chris@ethereum.org> | 2018-11-09 23:07:20 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-09 23:07:20 +0800 |
commit | 9709dfe04633ddb5e7d9911cdef1f4de54e5592e (patch) | |
tree | 2a30bcc226d55b80207ff5fc09d9befaffd9fb99 /test/libyul | |
parent | dffbeebf606c41442fd79bdaf59cfa6649ffc0d0 (diff) | |
parent | 5ea514213a2ba15a8190f0171ddc003607faa679 (diff) | |
download | dexon-solidity-9709dfe04633ddb5e7d9911cdef1f4de54e5592e.tar dexon-solidity-9709dfe04633ddb5e7d9911cdef1f4de54e5592e.tar.gz dexon-solidity-9709dfe04633ddb5e7d9911cdef1f4de54e5592e.tar.bz2 dexon-solidity-9709dfe04633ddb5e7d9911cdef1f4de54e5592e.tar.lz dexon-solidity-9709dfe04633ddb5e7d9911cdef1f4de54e5592e.tar.xz dexon-solidity-9709dfe04633ddb5e7d9911cdef1f4de54e5592e.tar.zst dexon-solidity-9709dfe04633ddb5e7d9911cdef1f4de54e5592e.zip |
Merge pull request #5128 from ethereum/breakUnbreak
[Yul] Test case that shows that break / unbreak are more or less inverse
Diffstat (limited to 'test/libyul')
-rw-r--r-- | test/libyul/YulOptimizerTest.cpp | 18 | ||||
-rw-r--r-- | test/libyul/yulOptimizerTests/splitJoin/control_flow.yul | 26 | ||||
-rw-r--r-- | test/libyul/yulOptimizerTests/splitJoin/functions.yul | 30 | ||||
-rw-r--r-- | test/libyul/yulOptimizerTests/splitJoin/smoke.yul | 5 |
4 files changed, 74 insertions, 5 deletions
diff --git a/test/libyul/YulOptimizerTest.cpp b/test/libyul/YulOptimizerTest.cpp index 38390035..162b167c 100644 --- a/test/libyul/YulOptimizerTest.cpp +++ b/test/libyul/YulOptimizerTest.cpp @@ -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(); diff --git a/test/libyul/yulOptimizerTests/splitJoin/control_flow.yul b/test/libyul/yulOptimizerTests/splitJoin/control_flow.yul new file mode 100644 index 00000000..ad609c74 --- /dev/null +++ b/test/libyul/yulOptimizerTests/splitJoin/control_flow.yul @@ -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)) +// } +// } +// } diff --git a/test/libyul/yulOptimizerTests/splitJoin/functions.yul b/test/libyul/yulOptimizerTests/splitJoin/functions.yul new file mode 100644 index 00000000..549fc550 --- /dev/null +++ b/test/libyul/yulOptimizerTests/splitJoin/functions.yul @@ -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)) +// } +// } diff --git a/test/libyul/yulOptimizerTests/splitJoin/smoke.yul b/test/libyul/yulOptimizerTests/splitJoin/smoke.yul new file mode 100644 index 00000000..4b133029 --- /dev/null +++ b/test/libyul/yulOptimizerTests/splitJoin/smoke.yul @@ -0,0 +1,5 @@ +{} +// ---- +// splitJoin +// { +// } |