{
let a := calldataload(0) // x1
let b := calldataload(2) // x2
mstore(100, 200) // x3
mstore(a, b) // x4
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
An approach for | |
https://github.com/ethereum/solidity/pull/11493/files#r651807831 | |
""" | |
# stack is modelled by an array of characters | |
stackAfter = ['a', 'x', 'b', 'e', 'x', 'b', 'd', 'a', 'z', 'c'] | |
# operation | |
# (a, b, c, d) -> (x, y, z) |
Click for a table of gas differences
reative = (ir_optimized - legacy_optimized) / legacy_optimized * 100
File name | IR-optimized | Legacy-Optimized | relative (%) |
---|---|---|---|
abiEncoderV1/abi_decode_v2_storage.sol | 193182 | 193405 | -0.115302 |
abiEncoderV1/abi_encode_calldata_slice.sol | 1034560 | 873928 | 18.3805 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -u /tmp/oldyul.txt /tmp/newyul.txt | |
--- /tmp/oldyul.txt 2021-06-23 15:41:31.859708208 +0200 | |
+++ /tmp/newyul.txt 2021-06-23 15:41:06.418758767 +0200 | |
@@ -28,11 +28,11 @@ | |
{ | |
if callvalue() { revert(_1, _1) } | |
if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) } | |
- let expr_mpos := allocate_memory_1132() | |
+ let expr_mpos := allocate_memory_1140() | |
mstore(expr_mpos, 0x2a) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <set> | |
/// `_sigma` denotes a vector of size say `n`. | |
/// Corresponds to a permutation of {0, 1, 2, ..., n - 1} | |
/// The value `_sigma[i]` means `i` is mapped to `_sigma[i]`. | |
/// | |
/// A cycle is a set {a_1, a_2, ..., a_N} such that | |
/// a_1 -> a_2; a_2 -> a_3, ..., a_{N-1} -> a_N; a_N -> a_1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Optimized IR: | |
/******************************************************* | |
,* WARNING * | |
,* Solidity to Yul compilation is still EXPERIMENTAL * | |
,* It can result in LOSS OF FUNDS or worse * | |
,* !USE AT YOUR OWN RISK! * | |
,*******************************************************/ | |
object "C_26" { | |
code { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
let x := 64 | |
// can be removed | |
mstore(x, 128) | |
if iszero(lt(calldatasize(), 4)) | |
{ | |
let _1 := 0 | |
if eq(0x8868a931, shr(224, calldataload(_1))) | |
{ | |
if callvalue() { revert(_1, _1) } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""A script to collect gas statistics and print it. | |
Dependencies: Parsec (https://pypi.org/project/parsec/) and Tabulate | |
https://pypi.org/project/tabulate/ | |
pip install parsec tabulate | |
Run from root project dir. | |
python3 scripts/gas_stats.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -u /tmp/old.txt /tmp/new.txt | |
--- /tmp/old.txt 2021-03-26 11:50:28.707345655 +0100 | |
+++ /tmp/new.txt 2021-03-26 11:50:03.290450403 +0100 | |
@@ -3,7 +3,7 @@ | |
======= <stdin>:Test ======= | |
EVM assembly: | |
- /* "<stdin>":0:210 contract Test {... */ | |
+ /* "<stdin>":0:233 contract Test {... */ | |
mstore(0x40, 0x80) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -u /tmp/jumpold.txt /tmp/jumpnew.txt | |
--- /tmp/jumpold.txt 2021-03-24 13:23:56.931683183 +0100 | |
+++ /tmp/jumpnew.txt 2021-03-24 13:23:41.046763769 +0100 | |
@@ -97,16 +97,18 @@ | |
iszero | |
tag_11 | |
jumpi | |
- /* "<stdin>":128:133 leave */ | |
- jump(tag_10) | |
+ /* "<stdin>":119:144 { if x { leave } y := 8 } */ |