diff options
-rw-r--r-- | libsolidity/interface/GasEstimator.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/libsolidity/interface/GasEstimator.cpp b/libsolidity/interface/GasEstimator.cpp index a496cc21..a532f86e 100644 --- a/libsolidity/interface/GasEstimator.cpp +++ b/libsolidity/interface/GasEstimator.cpp @@ -136,13 +136,22 @@ GasEstimator::GasConsumption GasEstimator::functionalEstimation( ExpressionClasses& classes = state->expressionClasses(); using Id = ExpressionClasses::Id; using Ids = vector<Id>; - // div(calldataload(0), 1 << 224) equals to hashValue Id hashValue = classes.find(u256(FixedHash<4>::Arith(FixedHash<4>(dev::keccak256(_signature))))); Id calldata = classes.find(Instruction::CALLDATALOAD, Ids{classes.find(u256(0))}); - classes.forceEqual(hashValue, Instruction::DIV, Ids{ - calldata, - classes.find(u256(1) << 224) - }); + if (!m_evmVersion.hasBitwiseShifting()) + // div(calldataload(0), 1 << 224) equals to hashValue + classes.forceEqual( + hashValue, + Instruction::DIV, + Ids{calldata, classes.find(u256(1) << 224)} + ); + else + // shr(0xe0, calldataload(0)) equals to hashValue + classes.forceEqual( + hashValue, + Instruction::SHR, + Ids{classes.find(u256(0xe0)), calldata} + ); // lt(calldatasize(), 4) equals to 0 (ignore the shortcut for fallback functions) classes.forceEqual( classes.find(u256(0)), |