Add optimization rule SUB(~0, X) -> NOT(X).

This commit is contained in:
Daniel Kirchner 2019-06-13 11:13:26 +02:00
parent 4aa0c9e079
commit 7f322c9433
2 changed files with 2 additions and 0 deletions

View File

@ -5,6 +5,7 @@ Language Features:
Compiler Features:
* Optimizer: Add rule to simplify SUB(~0, X) to NOT(X).

View File

@ -124,6 +124,7 @@ std::vector<SimplificationRule<Pattern>> simplificationRuleListPart2(
{{Instruction::ADD, {X, 0}}, [=]{ return X; }, false},
{{Instruction::ADD, {0, X}}, [=]{ return X; }, false},
{{Instruction::SUB, {X, 0}}, [=]{ return X; }, false},
{{Instruction::SUB, {~u256(0), X}}, [=]() -> Pattern { return {Instruction::NOT, {X}}; }, false},
{{Instruction::MUL, {X, 0}}, [=]{ return u256(0); }, true},
{{Instruction::MUL, {0, X}}, [=]{ return u256(0); }, true},
{{Instruction::MUL, {X, 1}}, [=]{ return X; }, false},