mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add constant optimiser for SHR/SHL instructions
This commit is contained in:
parent
fe61435c27
commit
cb352edd26
@ -6,6 +6,7 @@ Features:
|
||||
* Commandline interface: Error when missing or inaccessible file detected. Suppress it with the ``--ignore-missing`` flag.
|
||||
* General: Support accessing dynamic return data in post-byzantium EVMs.
|
||||
* Interfaces: Allow overriding external functions in interfaces with public in an implementing contract.
|
||||
* Optimizer: Optimize ``SHL`` and ``SHR`` only involving constants (Constantinople only).
|
||||
* Optimizer: Remove useless ``SWAP1`` instruction preceding a commutative instruction (such as ``ADD``, ``MUL``, etc).
|
||||
* Optimizer: Replace comparison operators (``LT``, ``GT``, etc) with opposites if preceded by ``SWAP1``, e.g. ``SWAP1 LT`` is replaced with ``GT``.
|
||||
* Optimizer: Optimize across ``mload`` if ``msize()`` is not used.
|
||||
|
@ -89,6 +89,16 @@ std::vector<SimplificationRule<Pattern>> simplificationRuleList(
|
||||
u256 mask = (u256(1) << testBit) - 1;
|
||||
return u256(boost::multiprecision::bit_test(B.d(), testBit) ? B.d() | ~mask : B.d() & mask);
|
||||
}, false},
|
||||
{{Instruction::SHL, {A, B}}, [=]{
|
||||
if (A.d() > 255)
|
||||
return u256(0);
|
||||
return u256(bigint(B.d()) << unsigned(A.d()));
|
||||
}, false},
|
||||
{{Instruction::SHR, {A, B}}, [=]{
|
||||
if (A.d() > 255)
|
||||
return u256(0);
|
||||
return B.d() >> unsigned(A.d());
|
||||
}, false},
|
||||
|
||||
// invariants involving known constants
|
||||
{{Instruction::ADD, {X, 0}}, [=]{ return X; }, false},
|
||||
|
Loading…
Reference in New Issue
Block a user