diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2018-03-29 16:56:51 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2018-05-01 03:34:43 +0800 |
commit | 22bfd3da41ae9efa6e68e884f722502ab3adcf50 (patch) | |
tree | deeac11c204b909258f040318cc8964d7d2dbf1f /libsolidity/codegen/ExpressionCompiler.cpp | |
parent | 5cce2e552baf1f7431c99500da74cb929360c3b8 (diff) | |
download | dexon-solidity-22bfd3da41ae9efa6e68e884f722502ab3adcf50.tar dexon-solidity-22bfd3da41ae9efa6e68e884f722502ab3adcf50.tar.gz dexon-solidity-22bfd3da41ae9efa6e68e884f722502ab3adcf50.tar.bz2 dexon-solidity-22bfd3da41ae9efa6e68e884f722502ab3adcf50.tar.lz dexon-solidity-22bfd3da41ae9efa6e68e884f722502ab3adcf50.tar.xz dexon-solidity-22bfd3da41ae9efa6e68e884f722502ab3adcf50.tar.zst dexon-solidity-22bfd3da41ae9efa6e68e884f722502ab3adcf50.zip |
Use native shift instructions on Constantinople
Diffstat (limited to 'libsolidity/codegen/ExpressionCompiler.cpp')
-rw-r--r-- | libsolidity/codegen/ExpressionCompiler.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 3cf46a9d..1a33fe7c 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -1706,13 +1706,22 @@ void ExpressionCompiler::appendShiftOperatorCode(Token::Value _operator, Type co m_context.appendConditionalInvalid(); } + m_context << Instruction::SWAP1; + // stack: value_to_shift shift_amount + switch (_operator) { case Token::SHL: - m_context << Instruction::SWAP1 << u256(2) << Instruction::EXP << Instruction::MUL; + if (m_context.evmVersion().hasBitwiseShifting()) + m_context << Instruction::SHL; + else + m_context << u256(2) << Instruction::EXP << Instruction::MUL; break; case Token::SAR: - m_context << Instruction::SWAP1 << u256(2) << Instruction::EXP << Instruction::SWAP1 << (c_valueSigned ? Instruction::SDIV : Instruction::DIV); + if (m_context.evmVersion().hasBitwiseShifting()) + m_context << (c_valueSigned ? Instruction::SAR : Instruction::SHR); + else + m_context << u256(2) << Instruction::EXP << Instruction::SWAP1 << (c_valueSigned ? Instruction::SDIV : Instruction::DIV); break; case Token::SHR: default: |