From 8d0b80f944c42e871e42c320dfabf92c707ed9b7 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 9 Nov 2016 11:28:53 +0000 Subject: Add test for SUB with 0 optimisation --- test/libsolidity/SolidityOptimizer.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'test/libsolidity') diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp index a53a2638..90caaab0 100644 --- a/test/libsolidity/SolidityOptimizer.cpp +++ b/test/libsolidity/SolidityOptimizer.cpp @@ -1304,6 +1304,28 @@ BOOST_AUTO_TEST_CASE(invalid_state_at_control_flow_join) compareVersions("test()"); } +BOOST_AUTO_TEST_CASE(cse_sub_zero) +{ + checkCSE({ + u256(0), + u256(5), + Instruction::SUB + }, { + u256(5) + }); + + checkCSE({ + u256(5), + u256(0), + Instruction::SUB + }, { + u256(5), + u256(0), + Instruction::SUB + }); +} + + BOOST_AUTO_TEST_SUITE_END() } -- cgit