Skip to content

Commit 85adca6

Browse files
author
Mohammad Rezaei
committed
remove runs based heuristic
1 parent 693d5aa commit 85adca6

File tree

98 files changed

+250
-253
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+250
-253
lines changed

Changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Language Features:
44

55

66
Compiler Features:
7-
* Constant Optimizer: Compute masks using shifts when optimizing for size; use an ``--optimizer-runs`` value less than 200 for maximum size reduction.
7+
* Constant Optimizer: Compute masks using shifts when optimizing for size.
88

99
Bugfixes:
1010
* SMTChecker: Fix incorrect analysis when only a subset of contracts is selected with `--model-checker-contracts`.

libevmasm/ConstantOptimiser.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,14 +257,11 @@ AssemblyItems ComputeMethod::findRepresentation(u256 const& _value)
257257
// check for masks first
258258
unsigned lowZeros = 0;
259259
unsigned highOnes = 0;
260-
//only fully optimize for size if the compiler parameters are not default of 200
261-
unsigned threshold1 = m_params.runs < 200 ? 32 : 128;
262-
unsigned threshold2 = m_params.runs < 200 ? 16 : 128;
263260
for (; ((_value >> lowZeros) & 1) == 0 && lowZeros < 256; lowZeros++) {}
264261
for (; ((_value >> (lowZeros + highOnes)) & 1) == 1 && highOnes < 256; highOnes++) {}
265-
if (m_params.evmVersion.hasBitwiseShifting() && highOnes > threshold1 &&
262+
if (m_params.evmVersion.hasBitwiseShifting() && highOnes > 32 &&
266263
((_value >> (lowZeros + highOnes)) == 0) &&
267-
((lowZeros + highOnes < 256) || lowZeros > threshold2))
264+
((lowZeros + highOnes < 256) || lowZeros > 16))
268265
{
269266
// this is a big enough mask to use zero negation
270267
AssemblyItems newRoutine = AssemblyItems{u256(0), Instruction::NOT};

test/cmdlineTests/optimizer_inliner_dynamic_reference/output

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ sub_0: assembly {
8484
/* "optimizer_inliner_dynamic_reference/input.sol":147:152 x = f */
8585
dup1
8686
sload
87-
not(0xffffffffffffffff)
87+
shl(0x40, not(0x00))
8888
and
8989
/* "optimizer_inliner_dynamic_reference/input.sol":151:152 f */
9090
tag_17

test/libsolidity/gasTests/abiv2_optimised.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ contract C {
1919
// optimize-yul: true
2020
// ----
2121
// creation:
22-
// codeDepositCost: 617600
23-
// executionCost: 649
24-
// totalCost: 618249
22+
// codeDepositCost: 605600
23+
// executionCost: 636
24+
// totalCost: 606236
2525
// external:
2626
// a(): 2283
2727
// b(uint256): 4649

test/libsolidity/semanticTests/abiEncodeDecode/abi_decode_simple_storage.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ contract C {
88
}
99
// ----
1010
// f(bytes): 0x20, 0x80, 0x21, 0x40, 0x7, "abcdefg" -> 0x21, 0x40, 0x7, "abcdefg"
11-
// gas irOptimized: 135499
11+
// gas irOptimized: 135563
1212
// gas legacy: 137095
13-
// gas legacyOptimized: 135823
13+
// gas legacyOptimized: 135879

test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2_storage.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ contract C {
2121
}
2222
// ----
2323
// f() -> 0x20, 0x8, 0x40, 0x3, 0x9, 0xa, 0xb
24-
// gas irOptimized: 203167
24+
// gas irOptimized: 203255
2525
// gas legacy: 206263
26-
// gas legacyOptimized: 203172
26+
// gas legacyOptimized: 203220

test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ contract C {
5959
// EVMVersion: >homestead
6060
// ----
6161
// test_bytes() ->
62-
// gas irOptimized: 308660
62+
// gas irOptimized: 310684
6363
// gas legacy: 305816
64-
// gas legacyOptimized: 247337
64+
// gas legacyOptimized: 248777
6565
// test_uint256() ->
66-
// gas irOptimized: 438474
66+
// gas irOptimized: 440498
6767
// gas legacy: 421304
68-
// gas legacyOptimized: 341672
68+
// gas legacyOptimized: 343112

test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ contract C {
6060
// EVMVersion: >homestead
6161
// ----
6262
// test_bytes() ->
63-
// gas irOptimized: 308660
63+
// gas irOptimized: 310684
6464
// gas legacy: 305816
65-
// gas legacyOptimized: 247337
65+
// gas legacyOptimized: 248777
6666
// test_uint256() ->
67-
// gas irOptimized: 438474
67+
// gas irOptimized: 440498
6868
// gas legacy: 421304
69-
// gas legacyOptimized: 341672
69+
// gas legacyOptimized: 343112

test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_function_inherited_in_v1_contract.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ contract C is B {
3030
}
3131
// ----
3232
// test() -> 77
33-
// gas irOptimized: 55113
34-
// gas irOptimized code: 56800
33+
// gas irOptimized: 55177
34+
// gas irOptimized code: 54400
3535
// gas legacy: 57266
3636
// gas legacy code: 94600
3737
// gas legacyOptimized: 55191

test/libsolidity/semanticTests/abiEncoderV2/calldata_array.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ contract C {
2020
// f(uint256[][1]): 32, 32, 0 -> true
2121
// f(uint256[][1]): 32, 32, 1, 42 -> true
2222
// f(uint256[][1]): 32, 32, 8, 421, 422, 423, 424, 425, 426, 427, 428 -> true
23-
// gas irOptimized: 118382
23+
// gas irOptimized: 118550
2424
// gas legacy: 101568
2525
// gas legacyOptimized: 119092

0 commit comments

Comments
 (0)