mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #8707 from ethereum/optimizeIdempotencies
Rules for optimizing idempotency for bitwise operations.
This commit is contained in:
commit
aa071af476
@ -6,6 +6,7 @@ Language Features:
|
||||
|
||||
|
||||
Compiler Features:
|
||||
* Optimizer: Simplify repeated AND and OR operations.
|
||||
|
||||
Bugfixes:
|
||||
* SMTChecker: Fix internal error when fixed points are used.
|
||||
|
@ -232,6 +232,28 @@ std::vector<SimplificationRule<Pattern>> simplificationRuleListPart4(
|
||||
};
|
||||
}
|
||||
|
||||
template <class Pattern>
|
||||
std::vector<SimplificationRule<Pattern>> simplificationRuleListPart4_5(
|
||||
Pattern,
|
||||
Pattern,
|
||||
Pattern,
|
||||
Pattern X,
|
||||
Pattern Y
|
||||
)
|
||||
{
|
||||
using Builtins = typename Pattern::Builtins;
|
||||
return std::vector<SimplificationRule<Pattern>>{
|
||||
// idempotent operations
|
||||
{Builtins::AND(Builtins::AND(X, Y), Y), [=]{ return Builtins::AND(X, Y); }, true},
|
||||
{Builtins::AND(Y, Builtins::AND(X, Y)), [=]{ return Builtins::AND(X, Y); }, true},
|
||||
{Builtins::AND(Builtins::AND(Y, X), Y), [=]{ return Builtins::AND(Y, X); }, true},
|
||||
{Builtins::AND(Y, Builtins::AND(Y, X)), [=]{ return Builtins::AND(Y, X); }, true},
|
||||
{Builtins::OR(Builtins::OR(X, Y), Y), [=]{ return Builtins::OR(X, Y); }, true},
|
||||
{Builtins::OR(Y, Builtins::OR(X, Y)), [=]{ return Builtins::OR(X, Y); }, true},
|
||||
{Builtins::OR(Builtins::OR(Y, X), Y), [=]{ return Builtins::OR(Y, X); }, true},
|
||||
{Builtins::OR(Y, Builtins::OR(Y, X)), [=]{ return Builtins::OR(Y, X); }, true},
|
||||
};
|
||||
}
|
||||
|
||||
template <class Pattern>
|
||||
std::vector<SimplificationRule<Pattern>> simplificationRuleListPart5(
|
||||
@ -663,6 +685,7 @@ std::vector<SimplificationRule<Pattern>> simplificationRuleList(
|
||||
rules += simplificationRuleListPart2(A, B, C, W, X);
|
||||
rules += simplificationRuleListPart3(A, B, C, W, X);
|
||||
rules += simplificationRuleListPart4(A, B, C, W, X);
|
||||
rules += simplificationRuleListPart4_5(A, B, C, W, X);
|
||||
rules += simplificationRuleListPart5(A, B, C, W, X);
|
||||
rules += simplificationRuleListPart6(A, B, C, W, X);
|
||||
rules += simplificationRuleListPart7(A, B, C, W, X);
|
||||
|
@ -0,0 +1,15 @@
|
||||
{
|
||||
let x := calldataload(0)
|
||||
let z := calldataload(1)
|
||||
let t := and(and(x, z), x)
|
||||
let w := or(or(x, z), x)
|
||||
}
|
||||
// ----
|
||||
// step: expressionSimplifier
|
||||
//
|
||||
// {
|
||||
// let x := calldataload(0)
|
||||
// let z := calldataload(1)
|
||||
// let t := and(x, z)
|
||||
// let w := or(x, z)
|
||||
// }
|
Loading…
Reference in New Issue
Block a user