Merge pull request #9362 from ethereum/swappedTagConjunctions

Remove unneccessary masking of tags.
This commit is contained in:
chriseth 2020-07-13 17:35:06 +02:00 committed by GitHub
commit a783449195
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -5,6 +5,7 @@ Language Features:
Compiler Features:
* Code Generator: Evaluate ``keccak256`` of string literals at compile-time.
* Peephole Optimizer: Remove unnecessary masking of tags.
Bugfixes:
* Type Checker: Fix overload resolution in combination with ``{value: ...}``.

View File

@ -290,9 +290,10 @@ struct TagConjunctions: SimplePeepholeOptimizerMethod<TagConjunctions, 3>
std::back_insert_iterator<AssemblyItems> _out
)
{
if (_and != Instruction::AND)
return false;
if (
_pushTag.type() == PushTag &&
_and == Instruction::AND &&
_pushConstant.type() == Push &&
(_pushConstant.data() & u256(0xFFFFFFFF)) == u256(0xFFFFFFFF)
)
@ -300,6 +301,16 @@ struct TagConjunctions: SimplePeepholeOptimizerMethod<TagConjunctions, 3>
*_out = _pushTag;
return true;
}
else if (
// tag and constant are swapped
_pushConstant.type() == PushTag &&
_pushTag.type() == Push &&
(_pushTag.data() & u256(0xFFFFFFFF)) == u256(0xFFFFFFFF)
)
{
*_out = _pushConstant;
return true;
}
else
return false;
}