mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Use shift directly instead of multiplication in constant optimizer.
This commit is contained in:
parent
9d291a86cc
commit
5824f5d42f
@ -211,11 +211,16 @@ AssemblyItems ComputeMethod::findRepresentation(u256 const& _value)
|
|||||||
if (lowerPart != 0)
|
if (lowerPart != 0)
|
||||||
newRoutine += findRepresentation(u256(abs(lowerPart)));
|
newRoutine += findRepresentation(u256(abs(lowerPart)));
|
||||||
if (m_params.evmVersion.hasBitwiseShifting())
|
if (m_params.evmVersion.hasBitwiseShifting())
|
||||||
newRoutine += AssemblyItems{u256(1), u256(bits), Instruction::SHL};
|
{
|
||||||
|
newRoutine += findRepresentation(upperPart);
|
||||||
|
newRoutine += AssemblyItems{u256(bits), Instruction::SHL};
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
newRoutine += AssemblyItems{u256(bits), u256(2), Instruction::EXP};
|
newRoutine += AssemblyItems{u256(bits), u256(2), Instruction::EXP};
|
||||||
if (upperPart != 1)
|
if (upperPart != 1)
|
||||||
newRoutine += findRepresentation(upperPart) + AssemblyItems{Instruction::MUL};
|
newRoutine += findRepresentation(upperPart) + AssemblyItems{Instruction::MUL};
|
||||||
|
}
|
||||||
if (lowerPart > 0)
|
if (lowerPart > 0)
|
||||||
newRoutine += AssemblyItems{Instruction::ADD};
|
newRoutine += AssemblyItems{Instruction::ADD};
|
||||||
else if (lowerPart < 0)
|
else if (lowerPart < 0)
|
||||||
|
@ -75,12 +75,12 @@ BOOST_AUTO_TEST_CASE(string_storage)
|
|||||||
else if (Options::get().useABIEncoderV2)
|
else if (Options::get().useABIEncoderV2)
|
||||||
{
|
{
|
||||||
if (Options::get().optimizeYul)
|
if (Options::get().optimizeYul)
|
||||||
CHECK_GAS(153631, 130633, 100);
|
CHECK_GAS(153631, 129829, 100);
|
||||||
else
|
else
|
||||||
CHECK_GAS(153631, 138351, 100);
|
CHECK_GAS(153631, 138351, 100);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
CHECK_GAS(129037, 122500, 100);
|
CHECK_GAS(129037, 121703, 100);
|
||||||
if (Options::get().evmVersion() >= EVMVersion::byzantium())
|
if (Options::get().evmVersion() >= EVMVersion::byzantium())
|
||||||
{
|
{
|
||||||
callContractFunction("f()");
|
callContractFunction("f()");
|
||||||
|
Loading…
Reference in New Issue
Block a user