aboutsummaryrefslogtreecommitdiffstats
path: root/test/libevmasm/Optimiser.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-05-16 20:43:57 +0800
committerGitHub <noreply@github.com>2018-05-16 20:43:57 +0800
commite67f0147998a9e3835ed3ce8bf6a0a0c634216c5 (patch)
treeb9c0b7d41cd9f78ae3404704a888da30e767edbe /test/libevmasm/Optimiser.cpp
parent124ca40dc525a987a88176c6e5170978e82fa290 (diff)
parent1e45d3ab2e0ca688c2ae48ab657f11496ccebc12 (diff)
downloaddexon-solidity-e67f0147998a9e3835ed3ce8bf6a0a0c634216c5.tar
dexon-solidity-e67f0147998a9e3835ed3ce8bf6a0a0c634216c5.tar.gz
dexon-solidity-e67f0147998a9e3835ed3ce8bf6a0a0c634216c5.tar.bz2
dexon-solidity-e67f0147998a9e3835ed3ce8bf6a0a0c634216c5.tar.lz
dexon-solidity-e67f0147998a9e3835ed3ce8bf6a0a0c634216c5.tar.xz
dexon-solidity-e67f0147998a9e3835ed3ce8bf6a0a0c634216c5.tar.zst
dexon-solidity-e67f0147998a9e3835ed3ce8bf6a0a0c634216c5.zip
Merge pull request #4148 from ethereum/develop
Merge develop into release for 0.4.24
Diffstat (limited to 'test/libevmasm/Optimiser.cpp')
-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()