mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Pattern matching for expression simplification.
This commit is contained in:
parent
782e69fbe4
commit
4e20d0fb6d
@ -240,6 +240,12 @@ BOOST_AUTO_TEST_CASE(cse_unneeded_items)
|
|||||||
checkCSE(input, input);
|
checkCSE(input, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(cse_constant_addition)
|
||||||
|
{
|
||||||
|
AssemblyItems input{u256(7), u256(8), Instruction::ADD};
|
||||||
|
checkCSE(input, {u256(7 + 8)});
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(cse_invariants)
|
BOOST_AUTO_TEST_CASE(cse_invariants)
|
||||||
{
|
{
|
||||||
AssemblyItems input{
|
AssemblyItems input{
|
||||||
@ -262,6 +268,41 @@ BOOST_AUTO_TEST_CASE(cse_subother)
|
|||||||
checkCSE({Instruction::SUB}, {Instruction::SUB});
|
checkCSE({Instruction::SUB}, {Instruction::SUB});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(cse_double_negation)
|
||||||
|
{
|
||||||
|
checkCSE({Instruction::DUP5, Instruction::NOT, Instruction::NOT}, {Instruction::DUP5});
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(cse_associativity)
|
||||||
|
{
|
||||||
|
AssemblyItems input{
|
||||||
|
Instruction::DUP1,
|
||||||
|
Instruction::DUP1,
|
||||||
|
u256(0),
|
||||||
|
Instruction::OR,
|
||||||
|
Instruction::OR
|
||||||
|
};
|
||||||
|
checkCSE(input, {Instruction::DUP1});
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(cse_associativity2)
|
||||||
|
{
|
||||||
|
AssemblyItems input{
|
||||||
|
u256(0),
|
||||||
|
Instruction::DUP2,
|
||||||
|
u256(2),
|
||||||
|
u256(1),
|
||||||
|
Instruction::DUP6,
|
||||||
|
Instruction::ADD,
|
||||||
|
u256(2),
|
||||||
|
Instruction::ADD,
|
||||||
|
Instruction::ADD,
|
||||||
|
Instruction::ADD,
|
||||||
|
Instruction::ADD
|
||||||
|
};
|
||||||
|
checkCSE(input, {Instruction::DUP2, Instruction::DUP2, Instruction::ADD, u256(5), Instruction::ADD});
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user