Merge pull request #6256 from ethereum/completeLtGtRules

Complete the GT/LT rules.
This commit is contained in:
chriseth 2019-03-13 12:08:34 +01:00 committed by GitHub
commit 4c1a9aa273
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -10,6 +10,7 @@ Language Features:
Compiler Features: Compiler Features:
* Optimizer: Add rules for ``lt``-comparisons with constants.
* Peephole Optimizer: Remove double ``iszero`` before ``jumpi``. * Peephole Optimizer: Remove double ``iszero`` before ``jumpi``.
* SMTChecker: Support enums without typecast. * SMTChecker: Support enums without typecast.
* SMTChecker: Support one-dimensional arrays. * SMTChecker: Support one-dimensional arrays.

View File

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