mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Optimize byte-after-shr for shift amounts that are not multiples of 8.
This commit is contained in:
parent
f079efe28c
commit
a3a9630d8b
@ -583,9 +583,7 @@ std::vector<SimplificationRule<Pattern>> simplificationRuleListPart7(
|
|||||||
Builtins::BYTE(A, Builtins::SHR(B, X)),
|
Builtins::BYTE(A, Builtins::SHR(B, X)),
|
||||||
[=]() -> Pattern { return Word(0); },
|
[=]() -> Pattern { return Word(0); },
|
||||||
true,
|
true,
|
||||||
[=] {
|
[=] { return A.d() < B.d() / 8; }
|
||||||
return B.d() % 8 == 0 && A.d() < Pattern::WordSize / 8 && B.d() <= Pattern::WordSize && A.d() < B.d() / 8;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
rules.push_back({
|
rules.push_back({
|
||||||
|
@ -3,7 +3,7 @@ from opcodes import *
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
byte(A, shr(B, X))
|
byte(A, shr(B, X))
|
||||||
given B % 8 == 0 && A < n_bits/8 && B <= n_bits && A < B / 8
|
given A < B / 8
|
||||||
->
|
->
|
||||||
0
|
0
|
||||||
"""
|
"""
|
||||||
@ -22,9 +22,6 @@ nonopt = BYTE(A, SHR(B, X))
|
|||||||
# Optimized result
|
# Optimized result
|
||||||
opt = 0
|
opt = 0
|
||||||
|
|
||||||
rule.require(B % 8 == 0)
|
|
||||||
rule.require(ULT(A, n_bits/8))
|
|
||||||
rule.require(ULE(B, n_bits))
|
|
||||||
rule.require(ULT(A, DIV(B,8)))
|
rule.require(ULT(A, DIV(B,8)))
|
||||||
|
|
||||||
rule.check(nonopt, opt)
|
rule.check(nonopt, opt)
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
sstore(0, byte(0, shr(0x9, calldataload(0))))
|
||||||
|
}
|
||||||
|
// ====
|
||||||
|
// EVMVersion: >=constantinople
|
||||||
|
// ----
|
||||||
|
// step: expressionSimplifier
|
||||||
|
//
|
||||||
|
// { sstore(0, 0) }
|
Loading…
Reference in New Issue
Block a user