mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #6159 from ethereum/more-optims
More optimiser rules for LT/GT/AND/BYTE and address cleanups
This commit is contained in:
commit
34082a2368
@ -11,8 +11,10 @@ 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: Do not mask with 160-bits after ``CREATE`` and ``CREATE2`` as they are guaranteed to return an address or 0.
|
||||
* Optimizer: Support shifts in the constant optimiser for Constantinople.
|
||||
* Yul Optimizer: Add rule to replace switch statements with const expr. with matching case body
|
||||
|
||||
|
@ -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}
|
||||
};
|
||||
}
|
||||
|
||||
@ -231,7 +237,9 @@ std::vector<SimplificationRule<Pattern>> simplificationRuleListPart5(
|
||||
Instruction::ADDRESS,
|
||||
Instruction::CALLER,
|
||||
Instruction::ORIGIN,
|
||||
Instruction::COINBASE
|
||||
Instruction::COINBASE,
|
||||
Instruction::CREATE,
|
||||
Instruction::CREATE2
|
||||
})
|
||||
{
|
||||
u256 const mask = (u256(1) << 160) - 1;
|
||||
|
Loading…
Reference in New Issue
Block a user