diff options
author | chriseth <chris@ethereum.org> | 2017-06-15 01:40:53 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2017-06-15 02:02:45 +0800 |
commit | e5b0ad562e550a092aa966d8f5b9cb15ca625255 (patch) | |
tree | 544751c45e8861ddec039217346b1d491589c208 /test | |
parent | f008ddf83646f6002a61a123cc94ad195a35dce4 (diff) | |
download | dexon-solidity-e5b0ad562e550a092aa966d8f5b9cb15ca625255.tar.gz dexon-solidity-e5b0ad562e550a092aa966d8f5b9cb15ca625255.tar.zst dexon-solidity-e5b0ad562e550a092aa966d8f5b9cb15ca625255.zip |
Peephole optimizer for double push.
Diffstat (limited to 'test')
-rw-r--r-- | test/libsolidity/SolidityOptimizer.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp index bdcdacff..7afbe04e 100644 --- a/test/libsolidity/SolidityOptimizer.cpp +++ b/test/libsolidity/SolidityOptimizer.cpp @@ -1189,6 +1189,32 @@ BOOST_AUTO_TEST_CASE(clear_unreachable_code) ); } +BOOST_AUTO_TEST_CASE(peephole_double_push) +{ + AssemblyItems items{ + u256(0), + u256(0), + u256(5), + u256(5), + u256(4), + u256(5) + }; + AssemblyItems expectation{ + u256(0), + Instruction::DUP1, + u256(5), + Instruction::DUP1, + u256(4), + u256(5) + }; + PeepholeOptimiser peepOpt(items); + BOOST_REQUIRE(peepOpt.optimise()); + BOOST_CHECK_EQUAL_COLLECTIONS( + items.begin(), items.end(), + expectation.begin(), expectation.end() + ); +} + BOOST_AUTO_TEST_CASE(computing_constants) { char const* sourceCode = R"( |