Also apply simplification rules that require multiple identical sub-expressions.

This commit is contained in:
chriseth
2018-02-06 22:51:30 +01:00
parent f7392cc698
commit 5523296eaa
5 changed files with 163 additions and 3 deletions
+24
View File
@@ -87,6 +87,30 @@ BOOST_AUTO_TEST_CASE(constant_propagation)
);
}
BOOST_AUTO_TEST_CASE(identity_rules_simple)
{
CHECK(
"{ let a := mload(0) let b := sub(a, a) }",
"{ let a := mload(0) let b := 0 }"
);
}
BOOST_AUTO_TEST_CASE(identity_rules_complex)
{
CHECK(
"{ let a := sub(calldataload(0), calldataload(0)) }",
"{ let a := 0 }"
);
}
BOOST_AUTO_TEST_CASE(identity_rules_negative)
{
CHECK(
"{ let a := sub(calldataload(1), calldataload(0)) }",
"{ let a := sub(calldataload(1), calldataload(0)) }"
);
}
BOOST_AUTO_TEST_CASE(including_function_calls)
{
CHECK(