More optimiser rules for LT/GT/AND/BYTE

This commit is contained in:
Alex Beregszaszi 2019-02-26 12:12:46 +00:00
parent 68e1bf47d5
commit 7aa2ee1775
2 changed files with 8 additions and 1 deletions

View File

@ -10,6 +10,7 @@ Compiler Features:
* Inline Assembly: Instructions unavailable to the currently configured EVM are errors now.
* SMTChecker: Do not report underflow/overflow if they always revert. This removes false positives when using ``SafeMath``.
* Static Analyzer: Warn about expressions with custom types when they have no effect.
* Optimizer: Add new rules with constants including ``LT``, ``GT``, ``AND`` and ``BYTE``.
* Optimizer: Add rule for shifts with constants for Constantinople.
* Optimizer: Combine multiple shifts with constant shift-by values into one.
* Optimizer: Support shifts in the constant optimiser for Constantinople.

View File

@ -108,7 +108,7 @@ std::vector<SimplificationRule<Pattern>> simplificationRuleListPart2(
Pattern,
Pattern,
Pattern X,
Pattern
Pattern Y
)
{
return std::vector<SimplificationRule<Pattern>> {
@ -146,6 +146,12 @@ std::vector<SimplificationRule<Pattern>> simplificationRuleListPart2(
{{Instruction::SHR, {0, X}}, [=]{ return X; }, false},
{{Instruction::SHL, {X, 0}}, [=]{ return u256(0); }, true},
{{Instruction::SHR, {X, 0}}, [=]{ return u256(0); }, true},
{{Instruction::LT, {X, 0}}, [=]{ return u256(0); }, true},
{{Instruction::GT, {X, 0}}, [=]() -> Pattern { return {Instruction::ISZERO, {{Instruction::ISZERO, {X}}}}; }, false},
{{Instruction::GT, {X, ~u256(0)}}, [=]{ return u256(0); }, true},
{{Instruction::GT, {0, X}}, [=]{ return u256(0); }, true},
{{Instruction::AND, {{Instruction::BYTE, {X, Y}}, {u256(0xff)}}}, [=]() -> Pattern { return {Instruction::BYTE, {X, Y}}; }, false},
{{Instruction::BYTE, {X, 31}}, [=]() -> Pattern { return {Instruction::AND, {X, u256(0xff)}}; }, false}
};
}