diff options
author | chriseth <chris@ethereum.org> | 2018-06-20 17:38:37 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-20 17:38:37 +0800 |
commit | ba7fbf11e72a4f9da149ac3c9b4c908e4f215250 (patch) | |
tree | 0321ccecdd76aa4a17bfc1614cf1ae1ad50e0f13 /test | |
parent | c9ff67ca3e55ba46f6cb4332158328db0c1d2660 (diff) | |
parent | 804eb3ef9d45cd9e4f57ba9b4bd60fea36135ca2 (diff) | |
download | dexon-solidity-ba7fbf11e72a4f9da149ac3c9b4c908e4f215250.tar dexon-solidity-ba7fbf11e72a4f9da149ac3c9b4c908e4f215250.tar.gz dexon-solidity-ba7fbf11e72a4f9da149ac3c9b4c908e4f215250.tar.bz2 dexon-solidity-ba7fbf11e72a4f9da149ac3c9b4c908e4f215250.tar.lz dexon-solidity-ba7fbf11e72a4f9da149ac3c9b4c908e4f215250.tar.xz dexon-solidity-ba7fbf11e72a4f9da149ac3c9b4c908e4f215250.tar.zst dexon-solidity-ba7fbf11e72a4f9da149ac3c9b4c908e4f215250.zip |
Merge pull request #4300 from nventuro/optimize-out-and
Add TruthyAnd Peephole optimization
Diffstat (limited to 'test')
-rw-r--r-- | test/libevmasm/Optimiser.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/libevmasm/Optimiser.cpp b/test/libevmasm/Optimiser.cpp index 4b399a14..5687ffcc 100644 --- a/test/libevmasm/Optimiser.cpp +++ b/test/libevmasm/Optimiser.cpp @@ -967,6 +967,31 @@ BOOST_AUTO_TEST_CASE(peephole_swap_comparison) } } +BOOST_AUTO_TEST_CASE(peephole_truthy_and) +{ + AssemblyItems items{ + AssemblyItem(Tag, 1), + Instruction::BALANCE, + u256(0), + Instruction::NOT, + Instruction::AND, + AssemblyItem(PushTag, 1), + Instruction::JUMPI + }; + AssemblyItems expectation{ + AssemblyItem(Tag, 1), + Instruction::BALANCE, + AssemblyItem(PushTag, 1), + Instruction::JUMPI + }; + PeepholeOptimiser peepOpt(items); + BOOST_REQUIRE(peepOpt.optimise()); + BOOST_CHECK_EQUAL_COLLECTIONS( + items.begin(), items.end(), + expectation.begin(), expectation.end() + ); +} + BOOST_AUTO_TEST_CASE(jumpdest_removal) { AssemblyItems items{ |