mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #7316 from ethereum/addByteOpt
Replace byte(A, X) by zero if A >= 32
This commit is contained in:
commit
3c963eb00e
@ -5,6 +5,7 @@ Language Features:
|
|||||||
|
|
||||||
|
|
||||||
Compiler Features:
|
Compiler Features:
|
||||||
|
* Optimizer: Add rule that replaces the BYTE opcode by 0 if the first argument is larger than 31.
|
||||||
|
|
||||||
|
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
|
@ -259,6 +259,14 @@ std::vector<SimplificationRule<Pattern>> simplificationRuleListPart5(
|
|||||||
[=]() { return A.d() >= 256; }
|
[=]() { return A.d() >= 256; }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Replace BYTE(A, X), A >= 32 with 0
|
||||||
|
rules.push_back({
|
||||||
|
{Instruction::BYTE, {A, X}},
|
||||||
|
[=]() -> Pattern { return u256(0); },
|
||||||
|
true,
|
||||||
|
[=]() { return A.d() >= 32; }
|
||||||
|
});
|
||||||
|
|
||||||
for (auto const& op: std::vector<Instruction>{
|
for (auto const& op: std::vector<Instruction>{
|
||||||
Instruction::ADDRESS,
|
Instruction::ADDRESS,
|
||||||
Instruction::CALLER,
|
Instruction::CALLER,
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
let a := calldataload(0)
|
||||||
|
let b := byte(33, a)
|
||||||
|
let c := byte(20, a)
|
||||||
|
// create cannot be removed.
|
||||||
|
let d := byte(33, create(0, 0, 0x20))
|
||||||
|
}
|
||||||
|
// ====
|
||||||
|
// step: expressionSimplifier
|
||||||
|
// ----
|
||||||
|
// {
|
||||||
|
// let a := calldataload(0)
|
||||||
|
// let b := 0
|
||||||
|
// let c := byte(20, a)
|
||||||
|
// let d := byte(33, create(0, 0, 0x20))
|
||||||
|
// }
|
Loading…
Reference in New Issue
Block a user