aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/codegen/CompilerUtils.cpp
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-03-29 16:56:51 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-05-01 03:34:43 +0800
commit22bfd3da41ae9efa6e68e884f722502ab3adcf50 (patch)
treedeeac11c204b909258f040318cc8964d7d2dbf1f /libsolidity/codegen/CompilerUtils.cpp
parent5cce2e552baf1f7431c99500da74cb929360c3b8 (diff)
downloaddexon-solidity-22bfd3da41ae9efa6e68e884f722502ab3adcf50.tar.gz
dexon-solidity-22bfd3da41ae9efa6e68e884f722502ab3adcf50.tar.zst
dexon-solidity-22bfd3da41ae9efa6e68e884f722502ab3adcf50.zip
Use native shift instructions on Constantinople
Diffstat (limited to 'libsolidity/codegen/CompilerUtils.cpp')
-rw-r--r--libsolidity/codegen/CompilerUtils.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp
index 4af7d905..46e81d49 100644
--- a/libsolidity/codegen/CompilerUtils.cpp
+++ b/libsolidity/codegen/CompilerUtils.cpp
@@ -1265,13 +1265,19 @@ void CompilerUtils::cleanHigherOrderBits(IntegerType const& _typeOnStack)
void CompilerUtils::leftShiftNumberOnStack(unsigned _bits)
{
solAssert(_bits < 256, "");
- m_context << (u256(1) << _bits) << Instruction::MUL;
+ if (m_context.evmVersion().hasBitwiseShifting())
+ m_context << _bits << Instruction::SHL;
+ else
+ m_context << (u256(1) << _bits) << Instruction::MUL;
}
void CompilerUtils::rightShiftNumberOnStack(unsigned _bits, bool _isSigned)
{
solAssert(_bits < 256, "");
- m_context << (u256(1) << _bits) << Instruction::SWAP1 << (_isSigned ? Instruction::SDIV : Instruction::DIV);
+ if (m_context.evmVersion().hasBitwiseShifting())
+ m_context << _bits << (_isSigned ? Instruction::SAR : Instruction::SHR);
+ else
+ m_context << (u256(1) << _bits) << Instruction::SWAP1 << (_isSigned ? Instruction::SDIV : Instruction::DIV);
}
unsigned CompilerUtils::prepareMemoryStore(Type const& _type, bool _padToWords)