mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Optimize exp when base is -1
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract C {
|
||||
function exp_neg_one(uint exponent) public returns(int) {
|
||||
return (-1)**exponent;
|
||||
}
|
||||
function exp_two(uint exponent) public returns(uint) {
|
||||
return 2**exponent;
|
||||
}
|
||||
function exp_zero(uint exponent) public returns(uint) {
|
||||
return 0**exponent;
|
||||
}
|
||||
function exp_one(uint exponent) public returns(uint) {
|
||||
return 1**exponent;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// optimize: false
|
||||
// optimize-yul: false
|
||||
// ----
|
||||
// creation:
|
||||
// codeDepositCost: 119800
|
||||
// executionCost: 165
|
||||
// totalCost: 119965
|
||||
// external:
|
||||
// exp_neg_one(uint256): 2259
|
||||
// exp_one(uint256): infinite
|
||||
// exp_two(uint256): infinite
|
||||
// exp_zero(uint256): infinite
|
||||
@@ -0,0 +1,29 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract C {
|
||||
function exp_neg_one(uint exponent) public returns(int) {
|
||||
return (-1)**exponent;
|
||||
}
|
||||
function exp_two(uint exponent) public returns(uint) {
|
||||
return 2**exponent;
|
||||
}
|
||||
function exp_zero(uint exponent) public returns(uint) {
|
||||
return 0**exponent;
|
||||
}
|
||||
function exp_one(uint exponent) public returns(uint) {
|
||||
return 1**exponent;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// optimize: true
|
||||
// optimize-yul: true
|
||||
// ----
|
||||
// creation:
|
||||
// codeDepositCost: 53200
|
||||
// executionCost: 105
|
||||
// totalCost: 53305
|
||||
// external:
|
||||
// exp_neg_one(uint256): 1962
|
||||
// exp_one(uint256): 1915
|
||||
// exp_two(uint256): 1893
|
||||
// exp_zero(uint256): 1937
|
||||
Reference in New Issue
Block a user