aboutsummaryrefslogtreecommitdiffstats
path: root/test/libevmasm
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-04-18 20:36:20 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-04-20 06:59:06 +0800
commit38460d8b473052bd9d4871ed7f10e72f8fb65615 (patch)
tree907f8f132c325df13bfdc2df1506fe0e2fedab09 /test/libevmasm
parent27d7990684dcd16486f107b61f8d6540530a2200 (diff)
downloaddexon-solidity-38460d8b473052bd9d4871ed7f10e72f8fb65615.tar.gz
dexon-solidity-38460d8b473052bd9d4871ed7f10e72f8fb65615.tar.zst
dexon-solidity-38460d8b473052bd9d4871ed7f10e72f8fb65615.zip
Remove unnecessary masking of the result of known short instructions
Diffstat (limited to 'test/libevmasm')
-rw-r--r--test/libevmasm/Optimiser.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/test/libevmasm/Optimiser.cpp b/test/libevmasm/Optimiser.cpp
index 089be45d..4b399a14 100644
--- a/test/libevmasm/Optimiser.cpp
+++ b/test/libevmasm/Optimiser.cpp
@@ -1072,6 +1072,75 @@ BOOST_AUTO_TEST_CASE(cse_sub_zero)
});
}
+BOOST_AUTO_TEST_CASE(cse_remove_unwanted_masking_of_address)
+{
+ vector<Instruction> ops{
+ Instruction::ADDRESS,
+ Instruction::CALLER,
+ Instruction::ORIGIN,
+ Instruction::COINBASE
+ };
+ for (auto const& op: ops)
+ {
+ checkCSE({
+ u256("0xffffffffffffffffffffffffffffffffffffffff"),
+ op,
+ Instruction::AND
+ }, {
+ op
+ });
+
+ checkCSE({
+ op,
+ u256("0xffffffffffffffffffffffffffffffffffffffff"),
+ Instruction::AND
+ }, {
+ op
+ });
+
+ // do not remove mask for other masking
+ checkCSE({
+ u256(1234),
+ op,
+ Instruction::AND
+ }, {
+ op,
+ u256(1234),
+ Instruction::AND
+ });
+
+ checkCSE({
+ op,
+ u256(1234),
+ Instruction::AND
+ }, {
+ u256(1234),
+ op,
+ Instruction::AND
+ });
+ }
+
+ // leave other opcodes untouched
+ checkCSE({
+ u256("0xffffffffffffffffffffffffffffffffffffffff"),
+ Instruction::CALLVALUE,
+ Instruction::AND
+ }, {
+ Instruction::CALLVALUE,
+ u256("0xffffffffffffffffffffffffffffffffffffffff"),
+ Instruction::AND
+ });
+
+ checkCSE({
+ Instruction::CALLVALUE,
+ u256("0xffffffffffffffffffffffffffffffffffffffff"),
+ Instruction::AND
+ }, {
+ u256("0xffffffffffffffffffffffffffffffffffffffff"),
+ Instruction::CALLVALUE,
+ Instruction::AND
+ });
+}
BOOST_AUTO_TEST_SUITE_END()