diff options
author | chriseth <chris@ethereum.org> | 2018-04-11 23:18:31 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-11 23:18:31 +0800 |
commit | d50d1f0ac1841a1d287a216451e93573fc07474e (patch) | |
tree | d24720a3bdf4d78de4436d88721e907ce91a367a /libevmasm/RuleList.h | |
parent | 29bde7fc2a6f6fc82b90f6963a536553b9eea04e (diff) | |
parent | 2e73ef5ac5db406e86e3a90c89d3be4b0d666073 (diff) | |
download | dexon-solidity-d50d1f0ac1841a1d287a216451e93573fc07474e.tar dexon-solidity-d50d1f0ac1841a1d287a216451e93573fc07474e.tar.gz dexon-solidity-d50d1f0ac1841a1d287a216451e93573fc07474e.tar.bz2 dexon-solidity-d50d1f0ac1841a1d287a216451e93573fc07474e.tar.lz dexon-solidity-d50d1f0ac1841a1d287a216451e93573fc07474e.tar.xz dexon-solidity-d50d1f0ac1841a1d287a216451e93573fc07474e.tar.zst dexon-solidity-d50d1f0ac1841a1d287a216451e93573fc07474e.zip |
Merge pull request #3580 from ethereum/asm-bitshift-optim
Add simplification rule for bitwise shifting
Diffstat (limited to 'libevmasm/RuleList.h')
-rw-r--r-- | libevmasm/RuleList.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libevmasm/RuleList.h b/libevmasm/RuleList.h index da522cec..abcf170c 100644 --- a/libevmasm/RuleList.h +++ b/libevmasm/RuleList.h @@ -89,6 +89,16 @@ std::vector<SimplificationRule<Pattern>> simplificationRuleList( u256 mask = (u256(1) << testBit) - 1; return u256(boost::multiprecision::bit_test(B.d(), testBit) ? B.d() | ~mask : B.d() & mask); }, false}, + {{Instruction::SHL, {A, B}}, [=]{ + if (A.d() > 255) + return u256(0); + return u256(bigint(B.d()) << unsigned(A.d())); + }, false}, + {{Instruction::SHR, {A, B}}, [=]{ + if (A.d() > 255) + return u256(0); + return B.d() >> unsigned(A.d()); + }, false}, // invariants involving known constants {{Instruction::ADD, {X, 0}}, [=]{ return X; }, false}, |