Replace shifts by larger than 255 with 0

This commit is contained in:
Alex Beregszaszi
2019-03-29 10:07:54 +01:00
committed by Mathias Baumann
parent 65026a0a25
commit 84fbf605aa
3 changed files with 60 additions and 1 deletions
+42
View File
@@ -1250,6 +1250,48 @@ BOOST_AUTO_TEST_CASE(cse_remove_unwanted_masking_of_address)
});
}
BOOST_AUTO_TEST_CASE(cse_replace_too_large_shift)
{
if (!dev::test::Options::get().evmVersion().hasBitwiseShifting())
return;
checkCSE({
Instruction::CALLVALUE,
u256(299),
Instruction::SHL
}, {
u256(0)
});
checkCSE({
Instruction::CALLVALUE,
u256(299),
Instruction::SHR
}, {
u256(0)
});
checkCSE({
Instruction::CALLVALUE,
u256(255),
Instruction::SHL
}, {
Instruction::CALLVALUE,
u256(255),
Instruction::SHL
});
checkCSE({
Instruction::CALLVALUE,
u256(255),
Instruction::SHR
}, {
Instruction::CALLVALUE,
u256(255),
Instruction::SHR
});
}
BOOST_AUTO_TEST_SUITE_END()
}