Optimize double ISZERO.

This commit is contained in:
chriseth 2015-06-06 12:42:36 +02:00
parent cad767de61
commit 7bdd1b1d4a

View File

@ -260,6 +260,22 @@ Rules::Rules()
{{Instruction::NOT, {{Instruction::NOT, {X}}}}, [=]{ return X; }}, {{Instruction::NOT, {{Instruction::NOT, {X}}}}, [=]{ return X; }},
}; };
// Double negation of opcodes with binary result
for (auto const& op: vector<Instruction>{
Instruction::EQ,
Instruction::LT,
Instruction::SLT,
Instruction::GT,
Instruction::SGT
})
m_rules.push_back({
{Instruction::ISZERO, {{Instruction::ISZERO, {{op, {X, Y}}}}}},
[=]() -> Pattern { return {op, {X, Y}}; }
});
m_rules.push_back({
{Instruction::ISZERO, {{Instruction::ISZERO, {{Instruction::ISZERO, {X}}}}}},
[=]() -> Pattern { return {Instruction::ISZERO, {X}}; }
});
// Associative operations // Associative operations
for (auto const& opFun: vector<pair<Instruction,function<u256(u256 const&,u256 const&)>>>{ for (auto const& opFun: vector<pair<Instruction,function<u256(u256 const&,u256 const&)>>>{
{Instruction::ADD, plus<u256>()}, {Instruction::ADD, plus<u256>()},