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') 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 From 4ff89dda1d9d81170b65775b33c1cfbd7e5e6b48 Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 14 Nov 2016 13:22:55 +0100 Subject: Update SolidityOptimizer.cpp --- test/libsolidity/SolidityOptimizer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp index 90caaab0..00a636fd 100644 --- a/test/libsolidity/SolidityOptimizer.cpp +++ b/test/libsolidity/SolidityOptimizer.cpp @@ -1308,18 +1308,18 @@ BOOST_AUTO_TEST_CASE(cse_sub_zero) { checkCSE({ u256(0), - u256(5), + Instruction::DUP2, Instruction::SUB }, { u256(5) }); checkCSE({ - u256(5), + Instruction::DUP2, u256(0), Instruction::SUB }, { - u256(5), + Instruction::DUP2, u256(0), Instruction::SUB }); -- cgit From 9a6a5f219b74097c1a11278aad07df1ffd60ff45 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 30 Nov 2016 11:18:33 +0000 Subject: Fix sub-0 optimiser test --- test/libsolidity/SolidityOptimizer.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp index 00a636fd..89c89adc 100644 --- a/test/libsolidity/SolidityOptimizer.cpp +++ b/test/libsolidity/SolidityOptimizer.cpp @@ -1311,16 +1311,17 @@ BOOST_AUTO_TEST_CASE(cse_sub_zero) Instruction::DUP2, Instruction::SUB }, { - u256(5) + Instruction::DUP1 }); checkCSE({ - Instruction::DUP2, + Instruction::DUP1, u256(0), Instruction::SUB }, { - Instruction::DUP2, u256(0), + Instruction::DUP2, + Instruction::SWAP1, Instruction::SUB }); } -- cgit