mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Only apply rules for yul optimizer
This commit is contained in:
parent
d1e382f2a8
commit
b99f85ec65
@ -275,6 +275,7 @@ std::vector<SimplificationRule<Pattern>> simplificationRuleListPart4_5(
|
|||||||
|
|
||||||
template <class Pattern>
|
template <class Pattern>
|
||||||
std::vector<SimplificationRule<Pattern>> simplificationRuleListPart5(
|
std::vector<SimplificationRule<Pattern>> simplificationRuleListPart5(
|
||||||
|
bool _forYulOptimizer,
|
||||||
Pattern A,
|
Pattern A,
|
||||||
Pattern B,
|
Pattern B,
|
||||||
Pattern,
|
Pattern,
|
||||||
@ -287,6 +288,9 @@ std::vector<SimplificationRule<Pattern>> simplificationRuleListPart5(
|
|||||||
|
|
||||||
std::vector<SimplificationRule<Pattern>> rules;
|
std::vector<SimplificationRule<Pattern>> rules;
|
||||||
|
|
||||||
|
// The libevmasm optimizer does not support rules resulting in opcodes with more than two arguments.
|
||||||
|
if (_forYulOptimizer)
|
||||||
|
{
|
||||||
// Replace MOD(MUL(X, Y), A) with MULMOD(X, Y, A) iff A=2**N
|
// Replace MOD(MUL(X, Y), A) with MULMOD(X, Y, A) iff A=2**N
|
||||||
rules.push_back({
|
rules.push_back({
|
||||||
Builtins::MOD(Builtins::MUL(X, Y), A),
|
Builtins::MOD(Builtins::MUL(X, Y), A),
|
||||||
@ -304,6 +308,7 @@ std::vector<SimplificationRule<Pattern>> simplificationRuleListPart5(
|
|||||||
return A.d() > 0 && ((A.d() & (A.d() - 1)) == 0);
|
return A.d() > 0 && ((A.d() & (A.d() - 1)) == 0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Replace MOD X, <power-of-two> with AND X, <power-of-two> - 1
|
// Replace MOD X, <power-of-two> with AND X, <power-of-two> - 1
|
||||||
for (size_t i = 0; i < Pattern::WordSize; ++i)
|
for (size_t i = 0; i < Pattern::WordSize; ++i)
|
||||||
@ -816,7 +821,7 @@ std::vector<SimplificationRule<Pattern>> simplificationRuleList(
|
|||||||
rules += simplificationRuleListPart3(A, B, C, W, X);
|
rules += simplificationRuleListPart3(A, B, C, W, X);
|
||||||
rules += simplificationRuleListPart4(A, B, C, W, X);
|
rules += simplificationRuleListPart4(A, B, C, W, X);
|
||||||
rules += simplificationRuleListPart4_5(A, B, C, W, X);
|
rules += simplificationRuleListPart4_5(A, B, C, W, X);
|
||||||
rules += simplificationRuleListPart5(A, B, C, W, X);
|
rules += simplificationRuleListPart5(_evmVersion.has_value(), A, B, C, W, X);
|
||||||
rules += simplificationRuleListPart6(A, B, C, W, X);
|
rules += simplificationRuleListPart6(A, B, C, W, X);
|
||||||
rules += simplificationRuleListPart7(A, B, C, W, X);
|
rules += simplificationRuleListPart7(A, B, C, W, X);
|
||||||
rules += simplificationRuleListPart8(A, B, C, W, X);
|
rules += simplificationRuleListPart8(A, B, C, W, X);
|
||||||
|
Loading…
Reference in New Issue
Block a user