aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-06-15 16:50:07 +0800
committerGitHub <noreply@github.com>2017-06-15 16:50:07 +0800
commitfb5db94879cdd6358d5b8a8a0097aff4b8dd680b (patch)
tree4ffd0a808868aa5e743ab1ebf66db77bb0d1da67 /test/libsolidity
parent1636602fc434da0b2d1a939870d2886facee209c (diff)
parent7af9d1000668c9628a2ee6294975cd7558ee1dbf (diff)
downloaddexon-solidity-fb5db94879cdd6358d5b8a8a0097aff4b8dd680b.tar.gz
dexon-solidity-fb5db94879cdd6358d5b8a8a0097aff4b8dd680b.tar.zst
dexon-solidity-fb5db94879cdd6358d5b8a8a0097aff4b8dd680b.zip
Merge pull request #2397 from ethereum/doublepush
Peephole optimizer for double push.
Diffstat (limited to 'test/libsolidity')
-rw-r--r--test/libsolidity/SolidityOptimizer.cpp26
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"(