mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Tests for FunctionSpecializer
This commit is contained in:
parent
45a3747701
commit
09998ceb0c
@ -14,9 +14,17 @@ object "object" {
|
||||
code {
|
||||
function main()
|
||||
{
|
||||
let _1 := 0
|
||||
mstore_internal(0:i32, _1, _1, _1, _1)
|
||||
mstore_internal(32:i32, _1, _1, _1, 1)
|
||||
let hi := i64.shl(i64.extend_i32_u(bswap32(i32.wrap_i64(0))), 32)
|
||||
let y := i64.or(hi, i64.extend_i32_u(bswap32(i32.wrap_i64(i64.shr_u(0, 32)))))
|
||||
i64.store(0:i32, y)
|
||||
i64.store(i32.add(0:i32, 8:i32), y)
|
||||
i64.store(i32.add(0:i32, 16:i32), y)
|
||||
i64.store(i32.add(0:i32, 24:i32), y)
|
||||
i64.store(32:i32, y)
|
||||
i64.store(i32.add(32:i32, 8:i32), y)
|
||||
i64.store(i32.add(32:i32, 16:i32), y)
|
||||
let hi_1 := i64.shl(i64.extend_i32_u(bswap32(i32.wrap_i64(1))), 32)
|
||||
i64.store(i32.add(32:i32, 24:i32), i64.or(hi_1, i64.extend_i32_u(bswap32(i32.wrap_i64(i64.shr_u(1, 32))))))
|
||||
eth.storageStore(0:i32, 32:i32)
|
||||
}
|
||||
function bswap16(x:i32) -> y:i32
|
||||
@ -28,24 +36,12 @@ object "object" {
|
||||
let hi:i32 := i32.shl(bswap16(x), 16:i32)
|
||||
y := i32.or(hi, bswap16(i32.shr_u(x, 16:i32)))
|
||||
}
|
||||
function bswap64(x) -> y
|
||||
{
|
||||
let hi := i64.shl(i64.extend_i32_u(bswap32(i32.wrap_i64(x))), 32)
|
||||
y := i64.or(hi, i64.extend_i32_u(bswap32(i32.wrap_i64(i64.shr_u(x, 32)))))
|
||||
}
|
||||
function mstore_internal(pos:i32, y1, y2, y3, y4)
|
||||
{
|
||||
i64.store(pos, bswap64(y1))
|
||||
i64.store(i32.add(pos, 8:i32), bswap64(y2))
|
||||
i64.store(i32.add(pos, 16:i32), bswap64(y3))
|
||||
i64.store(i32.add(pos, 24:i32), bswap64(y4))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Binary representation:
|
||||
0061736d01000000011b0560000060017e017e60017f017f60057f7e7e7e7e0060027f7f0002190108657468657265756d0c73746f7261676553746f7265000403060500020201030503010001060100071102066d656d6f72790200046d61696e00010ac001052901017e0240420021004100200020002000200010054120200020002000420110054100412010000b0b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100241107421022002200041107610027221010b20010b2201027e02402000a71003ad422086210220022000422088a71003ad8421010b20010b32000240200020011004370000200041086a20021004370000200041106a20031004370000200041186a200410043700000b0b
|
||||
0061736d01000000010e0360000060017f017f60027f7f0002190108657468657265756d0c73746f7261676553746f726500020304030001010503010001060100071102066d656d6f72790200046d61696e00010ac70103850101037e02404200a71003ad422086210020004200422088a71003ad84210141002001370000410041086a2001370000410041106a2001370000410041186a200137000041202001370000412041086a2001370000412041106a20013700004201a71003ad4220862102412041186a20024201422088a71003ad843700004100412010000b0b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100241107421022002200041107610027221010b20010b
|
||||
|
||||
Text representation:
|
||||
(module
|
||||
@ -54,11 +50,21 @@ Text representation:
|
||||
(export "main" (func $main))
|
||||
|
||||
(func $main
|
||||
(local $_1 i64)
|
||||
(local $hi i64)
|
||||
(local $y i64)
|
||||
(local $hi_1 i64)
|
||||
(block $label_
|
||||
(local.set $_1 (i64.const 0))
|
||||
(call $mstore_internal (i32.const 0) (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1))
|
||||
(call $mstore_internal (i32.const 32) (local.get $_1) (local.get $_1) (local.get $_1) (i64.const 1))
|
||||
(local.set $hi (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.const 0)))) (i64.const 32)))
|
||||
(local.set $y (i64.or (local.get $hi) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (i64.const 0) (i64.const 32)))))))
|
||||
(i64.store (i32.const 0) (local.get $y))
|
||||
(i64.store (i32.add (i32.const 0) (i32.const 8)) (local.get $y))
|
||||
(i64.store (i32.add (i32.const 0) (i32.const 16)) (local.get $y))
|
||||
(i64.store (i32.add (i32.const 0) (i32.const 24)) (local.get $y))
|
||||
(i64.store (i32.const 32) (local.get $y))
|
||||
(i64.store (i32.add (i32.const 32) (i32.const 8)) (local.get $y))
|
||||
(i64.store (i32.add (i32.const 32) (i32.const 16)) (local.get $y))
|
||||
(local.set $hi_1 (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.const 1)))) (i64.const 32)))
|
||||
(i64.store (i32.add (i32.const 32) (i32.const 24)) (i64.or (local.get $hi_1) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (i64.const 1) (i64.const 32)))))))
|
||||
(call $eth.storageStore (i32.const 0) (i32.const 32))
|
||||
)
|
||||
)
|
||||
@ -87,31 +93,4 @@ Text representation:
|
||||
(local.get $y)
|
||||
)
|
||||
|
||||
(func $bswap64
|
||||
(param $x i64)
|
||||
(result i64)
|
||||
(local $y i64)
|
||||
(local $hi i64)
|
||||
(block $label__3
|
||||
(local.set $hi (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (local.get $x)))) (i64.const 32)))
|
||||
(local.set $y (i64.or (local.get $hi) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (local.get $x) (i64.const 32)))))))
|
||||
|
||||
)
|
||||
(local.get $y)
|
||||
)
|
||||
|
||||
(func $mstore_internal
|
||||
(param $pos i32)
|
||||
(param $y1 i64)
|
||||
(param $y2 i64)
|
||||
(param $y3 i64)
|
||||
(param $y4 i64)
|
||||
(block $label__4
|
||||
(i64.store (local.get $pos) (call $bswap64 (local.get $y1)))
|
||||
(i64.store (i32.add (local.get $pos) (i32.const 8)) (call $bswap64 (local.get $y2)))
|
||||
(i64.store (i32.add (local.get $pos) (i32.const 16)) (call $bswap64 (local.get $y3)))
|
||||
(i64.store (i32.add (local.get $pos) (i32.const 24)) (call $bswap64 (local.get $y4)))
|
||||
)
|
||||
)
|
||||
|
||||
)
|
||||
|
@ -24,68 +24,64 @@ object "object" {
|
||||
code {
|
||||
function main()
|
||||
{
|
||||
let _1 := 0
|
||||
let x, x_1, x_2, x_3 := calldataload(_1, _1, _1, _1)
|
||||
let x, x_1, x_2, x_3 := calldataload()
|
||||
let x_4 := x
|
||||
let x_5 := x_1
|
||||
let x_6 := x_2
|
||||
let x_7 := x_3
|
||||
let _2 := 1
|
||||
let _3:i32 := i32.eqz(i32.eqz(i64.eqz(i64.or(i64.or(_1, _1), i64.or(_1, _2)))))
|
||||
let _1:i32 := i32.eqz(i32.eqz(i64.eqz(i64.or(i64.or(0, 0), i64.or(0, 1)))))
|
||||
for { }
|
||||
i32.eqz(_3)
|
||||
i32.eqz(_1)
|
||||
{
|
||||
let x_8, x_9, x_10, x_11 := add(x_4, x_5, x_6, x_7, _1, _1, _1, _2)
|
||||
let x_8, x_9, x_10, x_11 := add(x_4, x_5, x_6, x_7)
|
||||
x_4 := x_8
|
||||
x_5 := x_9
|
||||
x_6 := x_10
|
||||
x_7 := x_11
|
||||
}
|
||||
{
|
||||
let _4, _5, _6, _7 := iszero_887(_1, _1, _1, lt(x_4, x_5, x_6, x_7, _1, _1, _1, 10))
|
||||
if i32.eqz(i64.eqz(i64.or(i64.or(_4, _5), i64.or(_6, _7)))) { break }
|
||||
let _8, _9, _10, _11 := eq_888(x_4, x_5, x_6, x_7, _1, _1, _1, 2)
|
||||
if i32.eqz(i64.eqz(i64.or(i64.or(_8, _9), i64.or(_10, _11)))) { break }
|
||||
let _12, _13, _14, _15 := eq_888(x_4, x_5, x_6, x_7, _1, _1, _1, 4)
|
||||
if i32.eqz(i64.eqz(i64.or(i64.or(_12, _13), i64.or(_14, _15)))) { continue }
|
||||
let _2, _3, _4, _5 := iszero_1300_2121(lt(x_4, x_5, x_6, x_7))
|
||||
if i32.eqz(i64.eqz(i64.or(i64.or(_2, _3), i64.or(_4, _5)))) { break }
|
||||
let _6, _7, _8, _9 := eq_740_2122(x_4, x_5, x_6, x_7)
|
||||
if i32.eqz(i64.eqz(i64.or(i64.or(_6, _7), i64.or(_8, _9)))) { break }
|
||||
let _10, _11, _12, _13 := eq_741_2123(x_4, x_5, x_6, x_7)
|
||||
if i32.eqz(i64.eqz(i64.or(i64.or(_10, _11), i64.or(_12, _13)))) { continue }
|
||||
}
|
||||
sstore(_1, _1, _1, _1, x_4, x_5, x_6, x_7)
|
||||
sstore(x_4, x_5, x_6, x_7)
|
||||
}
|
||||
function add_carry(x, y, c) -> r, r_c
|
||||
function add(x1, x2, x3, x4) -> r1, r2, r3, r4
|
||||
{
|
||||
let t := i64.add(x, y)
|
||||
r := i64.add(t, c)
|
||||
r_c := i64.extend_i32_u(i32.or(i64.lt_u(t, x), i64.lt_u(r, t)))
|
||||
}
|
||||
function add(x1, x2, x3, x4, y1, y2, y3, y4) -> r1, r2, r3, r4
|
||||
{
|
||||
let t := i64.add(x4, y4)
|
||||
let t := i64.add(x4, 1)
|
||||
r4 := i64.add(t, 0)
|
||||
let r3_1, carry := add_carry(x3, y3, i64.extend_i32_u(i32.or(i64.lt_u(t, x4), i64.lt_u(r4, t))))
|
||||
r3 := r3_1
|
||||
let r2_1, carry_1 := add_carry(x2, y2, carry)
|
||||
r2 := r2_1
|
||||
let r1_1, carry_2 := add_carry(x1, y1, carry_1)
|
||||
r1 := r1_1
|
||||
let t_1 := i64.add(x3, 0)
|
||||
r3 := i64.add(t_1, i64.extend_i32_u(i32.or(i64.lt_u(t, x4), i64.lt_u(r4, t))))
|
||||
let t_2 := i64.add(x2, 0)
|
||||
r2 := i64.add(t_2, i64.extend_i32_u(i32.or(i64.lt_u(t_1, x3), i64.lt_u(r3, t_1))))
|
||||
r1 := i64.add(i64.add(x1, 0), i64.extend_i32_u(i32.or(i64.lt_u(t_2, x2), i64.lt_u(r2, t_2))))
|
||||
}
|
||||
function iszero_887(x1, x2, x3, x4) -> r1, r2, r3, r4
|
||||
function iszero_1300_2121(x4) -> r1, r2, r3, r4
|
||||
{
|
||||
r4 := i64.extend_i32_u(i64.eqz(i64.or(i64.or(x1, x2), i64.or(x3, x4))))
|
||||
r4 := i64.extend_i32_u(i64.eqz(i64.or(i64.or(0, 0), i64.or(0, x4))))
|
||||
}
|
||||
function eq_888(x1, x2, x3, x4, y1, y2, y3, y4) -> r1, r2, r3, r4
|
||||
function eq_740_2122(x1, x2, x3, x4) -> r1, r2, r3, r4
|
||||
{
|
||||
r4 := i64.extend_i32_u(i32.and(i64.eq(x1, y1), i32.and(i64.eq(x2, y2), i32.and(i64.eq(x3, y3), i64.eq(x4, y4)))))
|
||||
r4 := i64.extend_i32_u(i32.and(i64.eq(x1, 0), i32.and(i64.eq(x2, 0), i32.and(i64.eq(x3, 0), i64.eq(x4, 2)))))
|
||||
}
|
||||
function lt(x1, x2, x3, x4, y1, y2, y3, y4) -> z4
|
||||
function eq_741_2123(x1, x2, x3, x4) -> r1, r2, r3, r4
|
||||
{
|
||||
r4 := i64.extend_i32_u(i32.and(i64.eq(x1, 0), i32.and(i64.eq(x2, 0), i32.and(i64.eq(x3, 0), i64.eq(x4, 4)))))
|
||||
}
|
||||
function lt(x1, x2, x3, x4) -> z4
|
||||
{
|
||||
let z:i32 := false
|
||||
let _1:i32 := 0xffffffff:i32
|
||||
switch i32.select(_1, i64.ne(x1, y1), i64.lt_u(x1, y1))
|
||||
let _1 := 0
|
||||
let _2:i32 := 0xffffffff:i32
|
||||
switch i32.select(_2, i64.ne(x1, _1), i64.lt_u(x1, _1))
|
||||
case 0:i32 {
|
||||
switch i32.select(_1, i64.ne(x2, y2), i64.lt_u(x2, y2))
|
||||
switch i32.select(_2, i64.ne(x2, _1), i64.lt_u(x2, _1))
|
||||
case 0:i32 {
|
||||
switch i32.select(_1, i64.ne(x3, y3), i64.lt_u(x3, y3))
|
||||
case 0:i32 { z := i64.lt_u(x4, y4) }
|
||||
switch i32.select(_2, i64.ne(x3, _1), i64.lt_u(x3, _1))
|
||||
case 0:i32 { z := i64.lt_u(x4, 10) }
|
||||
case 1:i32 { z := 0:i32 }
|
||||
default { z := 1:i32 }
|
||||
}
|
||||
@ -96,11 +92,18 @@ object "object" {
|
||||
default { z := 1:i32 }
|
||||
z4 := i64.extend_i32_u(z)
|
||||
}
|
||||
function u256_to_i32(x1, x2, x3, x4) -> v:i32
|
||||
function u256_to_i32_744() -> v:i32
|
||||
{
|
||||
if i64.ne(0, i64.or(i64.or(x1, x2), x3)) { unreachable() }
|
||||
if i64.ne(0, i64.shr_u(x4, 32)) { unreachable() }
|
||||
v := i32.wrap_i64(x4)
|
||||
if i64.ne(0, i64.or(i64.or(0, 0), 0)) { unreachable() }
|
||||
if i64.ne(0, i64.shr_u(32, 32)) { unreachable() }
|
||||
v := i32.wrap_i64(32)
|
||||
}
|
||||
function u256_to_i32() -> v:i32
|
||||
{
|
||||
let _1 := 0
|
||||
if i64.ne(_1, i64.or(i64.or(_1, _1), _1)) { unreachable() }
|
||||
if i64.ne(_1, i64.shr_u(_1, 32)) { unreachable() }
|
||||
v := i32.wrap_i64(_1)
|
||||
}
|
||||
function bswap16(x:i32) -> y:i32
|
||||
{
|
||||
@ -116,59 +119,66 @@ object "object" {
|
||||
let hi := i64.shl(i64.extend_i32_u(bswap32(i32.wrap_i64(x))), 32)
|
||||
y := i64.or(hi, i64.extend_i32_u(bswap32(i32.wrap_i64(i64.shr_u(x, 32)))))
|
||||
}
|
||||
function calldataload(x1, x2, x3, x4) -> z1, z2, z3, z4
|
||||
function calldataload() -> z1, z2, z3, z4
|
||||
{
|
||||
let cds:i32 := eth.getCallDataSize()
|
||||
let _1 := 0
|
||||
let destination:i32 := u256_to_i32(_1, _1, _1, _1)
|
||||
let offset:i32 := u256_to_i32(x1, x2, x3, x4)
|
||||
let requested_size:i32 := u256_to_i32(_1, _1, _1, 32)
|
||||
if i64.ne(_1, i64.or(i64.or(_1, _1), _1)) { unreachable() }
|
||||
if i64.ne(_1, i64.shr_u(_1, 32)) { unreachable() }
|
||||
let v:i32 := i32.wrap_i64(_1)
|
||||
let offset:i32 := u256_to_i32()
|
||||
let requested_size:i32 := u256_to_i32_744()
|
||||
if i32.gt_u(offset, i32.sub(0xffffffff:i32, requested_size)) { eth.revert(0:i32, 0:i32) }
|
||||
let available_size:i32 := i32.sub(cds, offset)
|
||||
if i32.gt_u(offset, cds) { available_size := 0:i32 }
|
||||
let _2:i32 := 0:i32
|
||||
if i32.gt_u(available_size, _2)
|
||||
{
|
||||
eth.callDataCopy(destination, offset, available_size)
|
||||
eth.callDataCopy(v, offset, available_size)
|
||||
}
|
||||
if i32.gt_u(requested_size, available_size)
|
||||
{
|
||||
let _3:i32 := i32.sub(requested_size, available_size)
|
||||
let _4:i32 := i32.add(destination, available_size)
|
||||
let _4:i32 := i32.add(v, available_size)
|
||||
let i:i32 := _2
|
||||
for { } i32.lt_u(i, _3) { i := i32.add(i, 1:i32) }
|
||||
{
|
||||
i32.store8(i32.add(_4, i), _2)
|
||||
}
|
||||
}
|
||||
let z1_1 := bswap64(i64.load(_2))
|
||||
let z2_1 := bswap64(i64.load(i32.add(_2, 8:i32)))
|
||||
let z3_1 := bswap64(i64.load(i32.add(_2, 16:i32)))
|
||||
let z4_1 := bswap64(i64.load(i32.add(_2, 24:i32)))
|
||||
let z1_1, z2_1, z3_1, z4_1 := mload_internal()
|
||||
z1 := z1_1
|
||||
z2 := z2_1
|
||||
z3 := z3_1
|
||||
z4 := z4_1
|
||||
}
|
||||
function sstore(x1, x2, x3, x4, y1, y2, y3, y4)
|
||||
function sstore(y1, y2, y3, y4)
|
||||
{
|
||||
mstore_internal(0:i32, x1, x2, x3, x4)
|
||||
mstore_internal(32:i32, y1, y2, y3, y4)
|
||||
let hi := i64.shl(i64.extend_i32_u(bswap32(i32.wrap_i64(0))), 32)
|
||||
let y := i64.or(hi, i64.extend_i32_u(bswap32(i32.wrap_i64(i64.shr_u(0, 32)))))
|
||||
i64.store(0:i32, y)
|
||||
i64.store(i32.add(0:i32, 8:i32), y)
|
||||
i64.store(i32.add(0:i32, 16:i32), y)
|
||||
i64.store(i32.add(0:i32, 24:i32), y)
|
||||
i64.store(32:i32, bswap64(y1))
|
||||
i64.store(i32.add(32:i32, 8:i32), bswap64(y2))
|
||||
i64.store(i32.add(32:i32, 16:i32), bswap64(y3))
|
||||
i64.store(i32.add(32:i32, 24:i32), bswap64(y4))
|
||||
eth.storageStore(0:i32, 32:i32)
|
||||
}
|
||||
function mstore_internal(pos:i32, y1, y2, y3, y4)
|
||||
function mload_internal() -> z1, z2, z3, z4
|
||||
{
|
||||
i64.store(pos, bswap64(y1))
|
||||
i64.store(i32.add(pos, 8:i32), bswap64(y2))
|
||||
i64.store(i32.add(pos, 16:i32), bswap64(y3))
|
||||
i64.store(i32.add(pos, 24:i32), bswap64(y4))
|
||||
z1 := bswap64(i64.load(0:i32))
|
||||
z2 := bswap64(i64.load(i32.add(0:i32, 8:i32)))
|
||||
z3 := bswap64(i64.load(i32.add(0:i32, 16:i32)))
|
||||
z4 := bswap64(i64.load(i32.add(0:i32, 24:i32)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Binary representation:
|
||||
0061736d0100000001530c6000006000017f60017e017e60037e7e7e017e60047e7e7e7e017e60047e7e7e7e017f60087e7e7e7e7e7e7e7e0060087e7e7e7e7e7e7e7e017e60017f017f60057f7e7e7e7e0060027f7f0060037f7f7f00025e0408657468657265756d0c73746f7261676553746f7265000a08657468657265756d06726576657274000a08657468657265756d0f67657443616c6c4461746153697a65000108657468657265756d0c63616c6c44617461436f7079000b030e0d0003070407070508080204060905030100010610037e0142000b7e0142000b7e0142000b071102066d656d6f72790200046d61696e00040ac0090dcb02030a7e017f107e02404200210002402000200020002000100e21012300210223012103230221040b20012105200221062003210720042108420121092000200084200020098484504545210a02400340200a45450d01024002402000200020002005200620072008200020002000420a10091007210b2300210c2301210d2302210e0b200b200c84200d200e8484504504400c030b0240200520062007200820002000200042021008210f2300211023012111230221120b200f201084201120128484504504400c030b024020052006200720082000200020004204100821132300211423012115230221160b2013201484201520168484504504400c010b0b0240200520062007200820002000200020091006211723002118230121192302211a0b201721052018210620192107201a21080c000b0b20002000200020002005200620072008100f0b0b2901037e0240200020017c2105200520027c21032005200054200320055472ad21040b2004240020030b6c010b7e0240200320077c210c200c42007c210b024020022006200c200354200b200c5472ad1005210d2300210e0b200d210a024020012005200e1005210f230021100b200f2109024020002004201010052111230021120b201121080b20092400200a2401200b240220080b2401047e0240200020018420022003848450ad21070b20052400200624012007240220040b2f01047e02402000200451200120055120022006512003200751717171ad210b0b20092400200a2401200b240220080ba30102017e057f024041002109417f210a0240200a200020045220002004541b210b200b41004604400240200a200120055220012005541b210c200c41004604400240200a200220065220022006541b210d200d41004604402003200754210905200d41014604404100210905410121090b0b0b05200c41014604404100210905410121090b0b0b05200b41014604404100210905410121090b0b0b2009ad21080b20080b2901017f024042002000200184200284520440000b42002003422088520440000b2003a721040b20040b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100b411074210220022000411076100b7221010b20010b2201027e02402000a7100cad422086210220022000422088a7100cad8421010b20010bfc0105047e017f017e087f047e024010022108420021092009200920092009100a210a2000200120022003100a210b2009200920094220100a210c200b417f200c6b4b04404100410010010b2008200b6b210d200b20084b04404100210d0b4100210e200d200e4b0440200a200b200d10030b200c200d4b0440200c200d6b210f200a200d6a2110200e2111024003402011200f49450d010240201020116a200e3a00000b201141016a21110c000b0b0b200e290000100d2112200e41086a290000100d2113200e41106a290000100d2114200e41186a290000100d2115201221042013210520142106201521070b20052400200624012007240220040b230002404100200020012002200310104120200420052006200710104100412010000b0b3200024020002001100d370000200041086a2002100d370000200041106a2003100d370000200041186a2004100d3700000b0b
|
||||
0061736d010000000130096000006000017e6000017f60017e017e60047e7e7e7e0060047e7e7e7e017e60017f017f60027f7f0060037f7f7f00025e0408657468657265756d0c73746f7261676553746f7265000708657468657265756d06726576657274000708657468657265756d0f67657443616c6c4461746153697a65000208657468657265756d0c63616c6c44617461436f70790008030f0e00050305050502020606030104010503010001061a057e0142000b7e0142000b7e0142000b7f0141000b7f0141000b071102066d656d6f72790200046d61696e00040a8a0a0e8d0203087e017f107e02400240100f21002300210123012102230221030b200021042001210520022106200321074200420084420042018484504545210802400340200845450d010240024020042005200620071009100621092303210a2304210b2300210c0b2009200a84200b200c8484504504400c030b024020042005200620071007210d2300210e2301210f230221100b200d200e84200f20108484504504400c030b02402004200520062007100821112300211223012113230221140b2011201284201320148484504504400c010b0b02402004200520062007100521152300211623012117230221180b201521042016210520172106201821070c000b0b200420052006200710100b0b6701077e0240200342017c2108200842007c2107200242007c210920092008200354200720085472ad7c2106200142007c210a200a2009200254200620095472ad7c2105200042007c200a2001542005200a5472ad7c21040b20052400200624012007240220040b2401047e0240420042008442002000848450ad21040b20022400200324012004240220010b2f01047e02402000420051200142005120024200512003420251717171ad21070b20052400200624012007240220040b2f01047e02402000420051200142005120024200512003420451717171ad21070b20052400200624012007240220040bab0104017e017f017e047f02404100210542002106417f210702402007200020065220002006541b21082008410046044002402007200120065220012006541b21092009410046044002402007200220065220022006541b210a200a41004604402003420a54210505200a41014604404100210505410121050b0b0b05200941014604404100210505410121050b0b0b05200841014604404100210505410121050b0b0b2005ad21040b20040b2901017f024042004200420084420084520440000b42004220422088520440000b4220a721000b20000b2f02017f017e02404200210120012001200184200184520440000b20012001422088520440000b2001a721000b20000b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100c411074210220022000411076100c7221010b20010b2201027e02402000a7100dad422086210220022000422088a7100dad8421010b20010be60105047e017f017e087f047e0240100221044200210520052005200584200584520440000b20052005422088520440000b2005a72106100b2107100a21082007417f20086b4b04404100410010010b200420076b2109200720044b0440410021090b4100210a2009200a4b044020062007200910030b200820094b0440200820096b210b200620096a210c200a210d02400340200d200b49450d010240200c200d6a200a3a00000b200d41016a210d0c000b0b0b02401011210e2300210f23012110230221110b200e2100200f210120102102201121030b20012400200224012003240220000b7801027e02404200a7100dad422086210420044200422088a7100dad84210541002005370000410041086a2005370000410041106a2005370000410041186a200537000041202000100e370000412041086a2001100e370000412041106a2002100e370000412041186a2003100e3700004100412010000b0b4201047e02404100290000100e2100410041086a290000100e2101410041106a290000100e2102410041186a290000100e21030b20012400200224012003240220000b
|
||||
|
||||
Text representation:
|
||||
(module
|
||||
@ -181,9 +191,10 @@ Text representation:
|
||||
(global $global_ (mut i64) (i64.const 0))
|
||||
(global $global__1 (mut i64) (i64.const 0))
|
||||
(global $global__2 (mut i64) (i64.const 0))
|
||||
(global $global__6 (mut i32) (i32.const 0))
|
||||
(global $global__7 (mut i32) (i32.const 0))
|
||||
|
||||
(func $main
|
||||
(local $_1 i64)
|
||||
(local $x i64)
|
||||
(local $x_1 i64)
|
||||
(local $x_2 i64)
|
||||
@ -192,8 +203,9 @@ Text representation:
|
||||
(local $x_5 i64)
|
||||
(local $x_6 i64)
|
||||
(local $x_7 i64)
|
||||
(local $_1 i32)
|
||||
(local $_2 i64)
|
||||
(local $_3 i32)
|
||||
(local $_3 i64)
|
||||
(local $_4 i64)
|
||||
(local $_5 i64)
|
||||
(local $_6 i64)
|
||||
@ -204,16 +216,13 @@ Text representation:
|
||||
(local $_11 i64)
|
||||
(local $_12 i64)
|
||||
(local $_13 i64)
|
||||
(local $_14 i64)
|
||||
(local $_15 i64)
|
||||
(local $x_8 i64)
|
||||
(local $x_9 i64)
|
||||
(local $x_10 i64)
|
||||
(local $x_11 i64)
|
||||
(block $label_
|
||||
(local.set $_1 (i64.const 0))
|
||||
(block
|
||||
(local.set $x (call $calldataload (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1)))
|
||||
(local.set $x (call $calldataload))
|
||||
(local.set $x_1 (global.get $global_))
|
||||
(local.set $x_2 (global.get $global__1))
|
||||
(local.set $x_3 (global.get $global__2))
|
||||
@ -223,46 +232,45 @@ Text representation:
|
||||
(local.set $x_5 (local.get $x_1))
|
||||
(local.set $x_6 (local.get $x_2))
|
||||
(local.set $x_7 (local.get $x_3))
|
||||
(local.set $_2 (i64.const 1))
|
||||
(local.set $_3 (i32.eqz (i32.eqz (i64.eqz (i64.or (i64.or (local.get $_1) (local.get $_1)) (i64.or (local.get $_1) (local.get $_2)))))))
|
||||
(local.set $_1 (i32.eqz (i32.eqz (i64.eqz (i64.or (i64.or (i64.const 0) (i64.const 0)) (i64.or (i64.const 0) (i64.const 1)))))))
|
||||
(block $label__3
|
||||
(loop $label__5
|
||||
(br_if $label__3 (i32.eqz (i32.eqz (local.get $_3))))
|
||||
(br_if $label__3 (i32.eqz (i32.eqz (local.get $_1))))
|
||||
(block $label__4
|
||||
(block
|
||||
(local.set $_4 (call $iszero_887 (local.get $_1) (local.get $_1) (local.get $_1) (call $lt (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7) (local.get $_1) (local.get $_1) (local.get $_1) (i64.const 10))))
|
||||
(local.set $_2 (call $iszero_1300_2121 (call $lt (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7))))
|
||||
(local.set $_3 (global.get $global__6))
|
||||
(local.set $_4 (global.get $global__7))
|
||||
(local.set $_5 (global.get $global_))
|
||||
(local.set $_6 (global.get $global__1))
|
||||
(local.set $_7 (global.get $global__2))
|
||||
|
||||
)
|
||||
(if (i32.eqz (i64.eqz (i64.or (i64.or (local.get $_4) (local.get $_5)) (i64.or (local.get $_6) (local.get $_7))))) (then
|
||||
(if (i32.eqz (i64.eqz (i64.or (i64.or (local.get $_2) (local.get $_3)) (i64.or (local.get $_4) (local.get $_5))))) (then
|
||||
(br $label__3)
|
||||
))
|
||||
(block
|
||||
(local.set $_8 (call $eq_888 (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7) (local.get $_1) (local.get $_1) (local.get $_1) (i64.const 2)))
|
||||
(local.set $_9 (global.get $global_))
|
||||
(local.set $_10 (global.get $global__1))
|
||||
(local.set $_11 (global.get $global__2))
|
||||
(local.set $_6 (call $eq_740_2122 (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7)))
|
||||
(local.set $_7 (global.get $global_))
|
||||
(local.set $_8 (global.get $global__1))
|
||||
(local.set $_9 (global.get $global__2))
|
||||
|
||||
)
|
||||
(if (i32.eqz (i64.eqz (i64.or (i64.or (local.get $_8) (local.get $_9)) (i64.or (local.get $_10) (local.get $_11))))) (then
|
||||
(if (i32.eqz (i64.eqz (i64.or (i64.or (local.get $_6) (local.get $_7)) (i64.or (local.get $_8) (local.get $_9))))) (then
|
||||
(br $label__3)
|
||||
))
|
||||
(block
|
||||
(local.set $_12 (call $eq_888 (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7) (local.get $_1) (local.get $_1) (local.get $_1) (i64.const 4)))
|
||||
(local.set $_13 (global.get $global_))
|
||||
(local.set $_14 (global.get $global__1))
|
||||
(local.set $_15 (global.get $global__2))
|
||||
(local.set $_10 (call $eq_741_2123 (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7)))
|
||||
(local.set $_11 (global.get $global_))
|
||||
(local.set $_12 (global.get $global__1))
|
||||
(local.set $_13 (global.get $global__2))
|
||||
|
||||
)
|
||||
(if (i32.eqz (i64.eqz (i64.or (i64.or (local.get $_12) (local.get $_13)) (i64.or (local.get $_14) (local.get $_15))))) (then
|
||||
(if (i32.eqz (i64.eqz (i64.or (i64.or (local.get $_10) (local.get $_11)) (i64.or (local.get $_12) (local.get $_13))))) (then
|
||||
(br $label__4)
|
||||
))
|
||||
|
||||
)
|
||||
(block
|
||||
(local.set $x_8 (call $add (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7) (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_2)))
|
||||
(local.set $x_8 (call $add (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7)))
|
||||
(local.set $x_9 (global.get $global_))
|
||||
(local.set $x_10 (global.get $global__1))
|
||||
(local.set $x_11 (global.get $global__2))
|
||||
@ -276,90 +284,31 @@ Text representation:
|
||||
)
|
||||
|
||||
)
|
||||
(call $sstore (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1) (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7))
|
||||
(call $sstore (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7))
|
||||
)
|
||||
)
|
||||
|
||||
(func $add_carry
|
||||
(param $x i64)
|
||||
(param $y i64)
|
||||
(param $c i64)
|
||||
(result i64)
|
||||
(local $r i64)
|
||||
(local $r_c i64)
|
||||
(local $t i64)
|
||||
(block $label__6
|
||||
(local.set $t (i64.add (local.get $x) (local.get $y)))
|
||||
(local.set $r (i64.add (local.get $t) (local.get $c)))
|
||||
(local.set $r_c (i64.extend_i32_u (i32.or (i64.lt_u (local.get $t) (local.get $x)) (i64.lt_u (local.get $r) (local.get $t)))))
|
||||
|
||||
)
|
||||
(global.set $global_ (local.get $r_c))
|
||||
(local.get $r)
|
||||
)
|
||||
|
||||
(func $add
|
||||
(param $x1 i64)
|
||||
(param $x2 i64)
|
||||
(param $x3 i64)
|
||||
(param $x4 i64)
|
||||
(param $y1 i64)
|
||||
(param $y2 i64)
|
||||
(param $y3 i64)
|
||||
(param $y4 i64)
|
||||
(result i64)
|
||||
(local $r1 i64)
|
||||
(local $r2 i64)
|
||||
(local $r3 i64)
|
||||
(local $r4 i64)
|
||||
(local $t i64)
|
||||
(local $r3_1 i64)
|
||||
(local $carry i64)
|
||||
(local $r2_1 i64)
|
||||
(local $carry_1 i64)
|
||||
(local $r1_1 i64)
|
||||
(local $carry_2 i64)
|
||||
(block $label__7
|
||||
(local.set $t (i64.add (local.get $x4) (local.get $y4)))
|
||||
(local.set $r4 (i64.add (local.get $t) (i64.const 0)))
|
||||
(block
|
||||
(local.set $r3_1 (call $add_carry (local.get $x3) (local.get $y3) (i64.extend_i32_u (i32.or (i64.lt_u (local.get $t) (local.get $x4)) (i64.lt_u (local.get $r4) (local.get $t))))))
|
||||
(local.set $carry (global.get $global_))
|
||||
|
||||
)
|
||||
(local.set $r3 (local.get $r3_1))
|
||||
(block
|
||||
(local.set $r2_1 (call $add_carry (local.get $x2) (local.get $y2) (local.get $carry)))
|
||||
(local.set $carry_1 (global.get $global_))
|
||||
|
||||
)
|
||||
(local.set $r2 (local.get $r2_1))
|
||||
(block
|
||||
(local.set $r1_1 (call $add_carry (local.get $x1) (local.get $y1) (local.get $carry_1)))
|
||||
(local.set $carry_2 (global.get $global_))
|
||||
|
||||
)
|
||||
(local.set $r1 (local.get $r1_1))
|
||||
|
||||
)
|
||||
(global.set $global_ (local.get $r2))
|
||||
(global.set $global__1 (local.get $r3))
|
||||
(global.set $global__2 (local.get $r4))
|
||||
(local.get $r1)
|
||||
)
|
||||
|
||||
(func $iszero_887
|
||||
(param $x1 i64)
|
||||
(param $x2 i64)
|
||||
(param $x3 i64)
|
||||
(param $x4 i64)
|
||||
(result i64)
|
||||
(local $r1 i64)
|
||||
(local $r2 i64)
|
||||
(local $r3 i64)
|
||||
(local $r4 i64)
|
||||
(local $t_1 i64)
|
||||
(local $t_2 i64)
|
||||
(block $label__8
|
||||
(local.set $r4 (i64.extend_i32_u (i64.eqz (i64.or (i64.or (local.get $x1) (local.get $x2)) (i64.or (local.get $x3) (local.get $x4))))))
|
||||
(local.set $t (i64.add (local.get $x4) (i64.const 1)))
|
||||
(local.set $r4 (i64.add (local.get $t) (i64.const 0)))
|
||||
(local.set $t_1 (i64.add (local.get $x3) (i64.const 0)))
|
||||
(local.set $r3 (i64.add (local.get $t_1) (i64.extend_i32_u (i32.or (i64.lt_u (local.get $t) (local.get $x4)) (i64.lt_u (local.get $r4) (local.get $t))))))
|
||||
(local.set $t_2 (i64.add (local.get $x2) (i64.const 0)))
|
||||
(local.set $r2 (i64.add (local.get $t_2) (i64.extend_i32_u (i32.or (i64.lt_u (local.get $t_1) (local.get $x3)) (i64.lt_u (local.get $r3) (local.get $t_1))))))
|
||||
(local.set $r1 (i64.add (i64.add (local.get $x1) (i64.const 0)) (i64.extend_i32_u (i32.or (i64.lt_u (local.get $t_2) (local.get $x2)) (i64.lt_u (local.get $r2) (local.get $t_2))))))
|
||||
|
||||
)
|
||||
(global.set $global_ (local.get $r2))
|
||||
@ -368,22 +317,55 @@ Text representation:
|
||||
(local.get $r1)
|
||||
)
|
||||
|
||||
(func $eq_888
|
||||
(param $x1 i64)
|
||||
(param $x2 i64)
|
||||
(param $x3 i64)
|
||||
(func $iszero_1300_2121
|
||||
(param $x4 i64)
|
||||
(param $y1 i64)
|
||||
(param $y2 i64)
|
||||
(param $y3 i64)
|
||||
(param $y4 i64)
|
||||
(result i64)
|
||||
(local $r1 i64)
|
||||
(local $r2 i64)
|
||||
(local $r3 i64)
|
||||
(local $r4 i64)
|
||||
(block $label__9
|
||||
(local.set $r4 (i64.extend_i32_u (i32.and (i64.eq (local.get $x1) (local.get $y1)) (i32.and (i64.eq (local.get $x2) (local.get $y2)) (i32.and (i64.eq (local.get $x3) (local.get $y3)) (i64.eq (local.get $x4) (local.get $y4)))))))
|
||||
(local.set $r4 (i64.extend_i32_u (i64.eqz (i64.or (i64.or (i64.const 0) (i64.const 0)) (i64.or (i64.const 0) (local.get $x4))))))
|
||||
|
||||
)
|
||||
(global.set $global_ (local.get $r2))
|
||||
(global.set $global__1 (local.get $r3))
|
||||
(global.set $global__2 (local.get $r4))
|
||||
(local.get $r1)
|
||||
)
|
||||
|
||||
(func $eq_740_2122
|
||||
(param $x1 i64)
|
||||
(param $x2 i64)
|
||||
(param $x3 i64)
|
||||
(param $x4 i64)
|
||||
(result i64)
|
||||
(local $r1 i64)
|
||||
(local $r2 i64)
|
||||
(local $r3 i64)
|
||||
(local $r4 i64)
|
||||
(block $label__10
|
||||
(local.set $r4 (i64.extend_i32_u (i32.and (i64.eq (local.get $x1) (i64.const 0)) (i32.and (i64.eq (local.get $x2) (i64.const 0)) (i32.and (i64.eq (local.get $x3) (i64.const 0)) (i64.eq (local.get $x4) (i64.const 2)))))))
|
||||
|
||||
)
|
||||
(global.set $global_ (local.get $r2))
|
||||
(global.set $global__1 (local.get $r3))
|
||||
(global.set $global__2 (local.get $r4))
|
||||
(local.get $r1)
|
||||
)
|
||||
|
||||
(func $eq_741_2123
|
||||
(param $x1 i64)
|
||||
(param $x2 i64)
|
||||
(param $x3 i64)
|
||||
(param $x4 i64)
|
||||
(result i64)
|
||||
(local $r1 i64)
|
||||
(local $r2 i64)
|
||||
(local $r3 i64)
|
||||
(local $r4 i64)
|
||||
(block $label__11
|
||||
(local.set $r4 (i64.extend_i32_u (i32.and (i64.eq (local.get $x1) (i64.const 0)) (i32.and (i64.eq (local.get $x2) (i64.const 0)) (i32.and (i64.eq (local.get $x3) (i64.const 0)) (i64.eq (local.get $x4) (i64.const 4)))))))
|
||||
|
||||
)
|
||||
(global.set $global_ (local.get $r2))
|
||||
@ -397,32 +379,30 @@ Text representation:
|
||||
(param $x2 i64)
|
||||
(param $x3 i64)
|
||||
(param $x4 i64)
|
||||
(param $y1 i64)
|
||||
(param $y2 i64)
|
||||
(param $y3 i64)
|
||||
(param $y4 i64)
|
||||
(result i64)
|
||||
(local $z4 i64)
|
||||
(local $z i32)
|
||||
(local $_1 i32)
|
||||
(local $_1 i64)
|
||||
(local $_2 i32)
|
||||
(local $condition i32)
|
||||
(local $condition_11 i32)
|
||||
(local $condition_12 i32)
|
||||
(block $label__10
|
||||
(local $condition_13 i32)
|
||||
(local $condition_14 i32)
|
||||
(block $label__12
|
||||
(local.set $z (i32.const 0))
|
||||
(local.set $_1 (i32.const 4294967295))
|
||||
(local.set $_1 (i64.const 0))
|
||||
(local.set $_2 (i32.const 4294967295))
|
||||
(block
|
||||
(local.set $condition (select (local.get $_1) (i64.ne (local.get $x1) (local.get $y1)) (i64.lt_u (local.get $x1) (local.get $y1))))
|
||||
(local.set $condition (select (local.get $_2) (i64.ne (local.get $x1) (local.get $_1)) (i64.lt_u (local.get $x1) (local.get $_1))))
|
||||
(if (i32.eq (local.get $condition) (i32.const 0)) (then
|
||||
(block
|
||||
(local.set $condition_11 (select (local.get $_1) (i64.ne (local.get $x2) (local.get $y2)) (i64.lt_u (local.get $x2) (local.get $y2))))
|
||||
(if (i32.eq (local.get $condition_11) (i32.const 0)) (then
|
||||
(local.set $condition_13 (select (local.get $_2) (i64.ne (local.get $x2) (local.get $_1)) (i64.lt_u (local.get $x2) (local.get $_1))))
|
||||
(if (i32.eq (local.get $condition_13) (i32.const 0)) (then
|
||||
(block
|
||||
(local.set $condition_12 (select (local.get $_1) (i64.ne (local.get $x3) (local.get $y3)) (i64.lt_u (local.get $x3) (local.get $y3))))
|
||||
(if (i32.eq (local.get $condition_12) (i32.const 0)) (then
|
||||
(local.set $z (i64.lt_u (local.get $x4) (local.get $y4)))
|
||||
(local.set $condition_14 (select (local.get $_2) (i64.ne (local.get $x3) (local.get $_1)) (i64.lt_u (local.get $x3) (local.get $_1))))
|
||||
(if (i32.eq (local.get $condition_14) (i32.const 0)) (then
|
||||
(local.set $z (i64.lt_u (local.get $x4) (i64.const 10)))
|
||||
)(else
|
||||
(if (i32.eq (local.get $condition_12) (i32.const 1)) (then
|
||||
(if (i32.eq (local.get $condition_14) (i32.const 1)) (then
|
||||
(local.set $z (i32.const 0))
|
||||
)(else
|
||||
(local.set $z (i32.const 1))
|
||||
@ -431,7 +411,7 @@ Text representation:
|
||||
|
||||
)
|
||||
)(else
|
||||
(if (i32.eq (local.get $condition_11) (i32.const 1)) (then
|
||||
(if (i32.eq (local.get $condition_13) (i32.const 1)) (then
|
||||
(local.set $z (i32.const 0))
|
||||
)(else
|
||||
(local.set $z (i32.const 1))
|
||||
@ -454,19 +434,31 @@ Text representation:
|
||||
(local.get $z4)
|
||||
)
|
||||
|
||||
(func $u256_to_i32
|
||||
(param $x1 i64)
|
||||
(param $x2 i64)
|
||||
(param $x3 i64)
|
||||
(param $x4 i64)
|
||||
(func $u256_to_i32_744
|
||||
(result i32)
|
||||
(local $v i32)
|
||||
(block $label__13
|
||||
(if (i64.ne (i64.const 0) (i64.or (i64.or (local.get $x1) (local.get $x2)) (local.get $x3))) (then
|
||||
(block $label__15
|
||||
(if (i64.ne (i64.const 0) (i64.or (i64.or (i64.const 0) (i64.const 0)) (i64.const 0))) (then
|
||||
(unreachable)))
|
||||
(if (i64.ne (i64.const 0) (i64.shr_u (local.get $x4) (i64.const 32))) (then
|
||||
(if (i64.ne (i64.const 0) (i64.shr_u (i64.const 32) (i64.const 32))) (then
|
||||
(unreachable)))
|
||||
(local.set $v (i32.wrap_i64 (local.get $x4)))
|
||||
(local.set $v (i32.wrap_i64 (i64.const 32)))
|
||||
|
||||
)
|
||||
(local.get $v)
|
||||
)
|
||||
|
||||
(func $u256_to_i32
|
||||
(result i32)
|
||||
(local $v i32)
|
||||
(local $_1 i64)
|
||||
(block $label__16
|
||||
(local.set $_1 (i64.const 0))
|
||||
(if (i64.ne (local.get $_1) (i64.or (i64.or (local.get $_1) (local.get $_1)) (local.get $_1))) (then
|
||||
(unreachable)))
|
||||
(if (i64.ne (local.get $_1) (i64.shr_u (local.get $_1) (i64.const 32))) (then
|
||||
(unreachable)))
|
||||
(local.set $v (i32.wrap_i64 (local.get $_1)))
|
||||
|
||||
)
|
||||
(local.get $v)
|
||||
@ -476,7 +468,7 @@ Text representation:
|
||||
(param $x i32)
|
||||
(result i32)
|
||||
(local $y i32)
|
||||
(block $label__14
|
||||
(block $label__17
|
||||
(local.set $y (i32.or (i32.and (i32.shl (local.get $x) (i32.const 8)) (i32.const 65280)) (i32.and (i32.shr_u (local.get $x) (i32.const 8)) (i32.const 255))))
|
||||
|
||||
)
|
||||
@ -488,7 +480,7 @@ Text representation:
|
||||
(result i32)
|
||||
(local $y i32)
|
||||
(local $hi i32)
|
||||
(block $label__15
|
||||
(block $label__18
|
||||
(local.set $hi (i32.shl (call $bswap16 (local.get $x)) (i32.const 16)))
|
||||
(local.set $y (i32.or (local.get $hi) (call $bswap16 (i32.shr_u (local.get $x) (i32.const 16)))))
|
||||
|
||||
@ -501,7 +493,7 @@ Text representation:
|
||||
(result i64)
|
||||
(local $y i64)
|
||||
(local $hi i64)
|
||||
(block $label__16
|
||||
(block $label__19
|
||||
(local.set $hi (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (local.get $x)))) (i64.const 32)))
|
||||
(local.set $y (i64.or (local.get $hi) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (local.get $x) (i64.const 32)))))))
|
||||
|
||||
@ -510,10 +502,6 @@ Text representation:
|
||||
)
|
||||
|
||||
(func $calldataload
|
||||
(param $x1 i64)
|
||||
(param $x2 i64)
|
||||
(param $x3 i64)
|
||||
(param $x4 i64)
|
||||
(result i64)
|
||||
(local $z1 i64)
|
||||
(local $z2 i64)
|
||||
@ -521,7 +509,7 @@ Text representation:
|
||||
(local $z4 i64)
|
||||
(local $cds i32)
|
||||
(local $_1 i64)
|
||||
(local $destination i32)
|
||||
(local $v i32)
|
||||
(local $offset i32)
|
||||
(local $requested_size i32)
|
||||
(local $available_size i32)
|
||||
@ -533,12 +521,16 @@ Text representation:
|
||||
(local $z2_1 i64)
|
||||
(local $z3_1 i64)
|
||||
(local $z4_1 i64)
|
||||
(block $label__17
|
||||
(block $label__20
|
||||
(local.set $cds (call $eth.getCallDataSize))
|
||||
(local.set $_1 (i64.const 0))
|
||||
(local.set $destination (call $u256_to_i32 (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1)))
|
||||
(local.set $offset (call $u256_to_i32 (local.get $x1) (local.get $x2) (local.get $x3) (local.get $x4)))
|
||||
(local.set $requested_size (call $u256_to_i32 (local.get $_1) (local.get $_1) (local.get $_1) (i64.const 32)))
|
||||
(if (i64.ne (local.get $_1) (i64.or (i64.or (local.get $_1) (local.get $_1)) (local.get $_1))) (then
|
||||
(unreachable)))
|
||||
(if (i64.ne (local.get $_1) (i64.shr_u (local.get $_1) (i64.const 32))) (then
|
||||
(unreachable)))
|
||||
(local.set $v (i32.wrap_i64 (local.get $_1)))
|
||||
(local.set $offset (call $u256_to_i32))
|
||||
(local.set $requested_size (call $u256_to_i32_744))
|
||||
(if (i32.gt_u (local.get $offset) (i32.sub (i32.const 4294967295) (local.get $requested_size))) (then
|
||||
(call $eth.revert (i32.const 0) (i32.const 0))))
|
||||
(local.set $available_size (i32.sub (local.get $cds) (local.get $offset)))
|
||||
@ -547,27 +539,30 @@ Text representation:
|
||||
))
|
||||
(local.set $_2 (i32.const 0))
|
||||
(if (i32.gt_u (local.get $available_size) (local.get $_2)) (then
|
||||
(call $eth.callDataCopy (local.get $destination) (local.get $offset) (local.get $available_size))))
|
||||
(call $eth.callDataCopy (local.get $v) (local.get $offset) (local.get $available_size))))
|
||||
(if (i32.gt_u (local.get $requested_size) (local.get $available_size)) (then
|
||||
(local.set $_3 (i32.sub (local.get $requested_size) (local.get $available_size)))
|
||||
(local.set $_4 (i32.add (local.get $destination) (local.get $available_size)))
|
||||
(local.set $_4 (i32.add (local.get $v) (local.get $available_size)))
|
||||
(local.set $i (local.get $_2))
|
||||
(block $label__18
|
||||
(loop $label__20
|
||||
(br_if $label__18 (i32.eqz (i32.lt_u (local.get $i) (local.get $_3))))
|
||||
(block $label__19
|
||||
(block $label__21
|
||||
(loop $label__23
|
||||
(br_if $label__21 (i32.eqz (i32.lt_u (local.get $i) (local.get $_3))))
|
||||
(block $label__22
|
||||
(i32.store8 (i32.add (local.get $_4) (local.get $i)) (local.get $_2))
|
||||
)
|
||||
(local.set $i (i32.add (local.get $i) (i32.const 1)))
|
||||
(br $label__20)
|
||||
(br $label__23)
|
||||
)
|
||||
|
||||
)
|
||||
))
|
||||
(local.set $z1_1 (call $bswap64 (i64.load (local.get $_2))))
|
||||
(local.set $z2_1 (call $bswap64 (i64.load (i32.add (local.get $_2) (i32.const 8)))))
|
||||
(local.set $z3_1 (call $bswap64 (i64.load (i32.add (local.get $_2) (i32.const 16)))))
|
||||
(local.set $z4_1 (call $bswap64 (i64.load (i32.add (local.get $_2) (i32.const 24)))))
|
||||
(block
|
||||
(local.set $z1_1 (call $mload_internal))
|
||||
(local.set $z2_1 (global.get $global_))
|
||||
(local.set $z3_1 (global.get $global__1))
|
||||
(local.set $z4_1 (global.get $global__2))
|
||||
|
||||
)
|
||||
(local.set $z1 (local.get $z1_1))
|
||||
(local.set $z2 (local.get $z2_1))
|
||||
(local.set $z3 (local.get $z3_1))
|
||||
@ -581,33 +576,44 @@ Text representation:
|
||||
)
|
||||
|
||||
(func $sstore
|
||||
(param $x1 i64)
|
||||
(param $x2 i64)
|
||||
(param $x3 i64)
|
||||
(param $x4 i64)
|
||||
(param $y1 i64)
|
||||
(param $y2 i64)
|
||||
(param $y3 i64)
|
||||
(param $y4 i64)
|
||||
(block $label__21
|
||||
(call $mstore_internal (i32.const 0) (local.get $x1) (local.get $x2) (local.get $x3) (local.get $x4))
|
||||
(call $mstore_internal (i32.const 32) (local.get $y1) (local.get $y2) (local.get $y3) (local.get $y4))
|
||||
(local $hi i64)
|
||||
(local $y i64)
|
||||
(block $label__24
|
||||
(local.set $hi (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.const 0)))) (i64.const 32)))
|
||||
(local.set $y (i64.or (local.get $hi) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (i64.const 0) (i64.const 32)))))))
|
||||
(i64.store (i32.const 0) (local.get $y))
|
||||
(i64.store (i32.add (i32.const 0) (i32.const 8)) (local.get $y))
|
||||
(i64.store (i32.add (i32.const 0) (i32.const 16)) (local.get $y))
|
||||
(i64.store (i32.add (i32.const 0) (i32.const 24)) (local.get $y))
|
||||
(i64.store (i32.const 32) (call $bswap64 (local.get $y1)))
|
||||
(i64.store (i32.add (i32.const 32) (i32.const 8)) (call $bswap64 (local.get $y2)))
|
||||
(i64.store (i32.add (i32.const 32) (i32.const 16)) (call $bswap64 (local.get $y3)))
|
||||
(i64.store (i32.add (i32.const 32) (i32.const 24)) (call $bswap64 (local.get $y4)))
|
||||
(call $eth.storageStore (i32.const 0) (i32.const 32))
|
||||
)
|
||||
)
|
||||
|
||||
(func $mstore_internal
|
||||
(param $pos i32)
|
||||
(param $y1 i64)
|
||||
(param $y2 i64)
|
||||
(param $y3 i64)
|
||||
(param $y4 i64)
|
||||
(block $label__22
|
||||
(i64.store (local.get $pos) (call $bswap64 (local.get $y1)))
|
||||
(i64.store (i32.add (local.get $pos) (i32.const 8)) (call $bswap64 (local.get $y2)))
|
||||
(i64.store (i32.add (local.get $pos) (i32.const 16)) (call $bswap64 (local.get $y3)))
|
||||
(i64.store (i32.add (local.get $pos) (i32.const 24)) (call $bswap64 (local.get $y4)))
|
||||
(func $mload_internal
|
||||
(result i64)
|
||||
(local $z1 i64)
|
||||
(local $z2 i64)
|
||||
(local $z3 i64)
|
||||
(local $z4 i64)
|
||||
(block $label__25
|
||||
(local.set $z1 (call $bswap64 (i64.load (i32.const 0))))
|
||||
(local.set $z2 (call $bswap64 (i64.load (i32.add (i32.const 0) (i32.const 8)))))
|
||||
(local.set $z3 (call $bswap64 (i64.load (i32.add (i32.const 0) (i32.const 16)))))
|
||||
(local.set $z4 (call $bswap64 (i64.load (i32.add (i32.const 0) (i32.const 24)))))
|
||||
|
||||
)
|
||||
(global.set $global_ (local.get $z2))
|
||||
(global.set $global__1 (local.get $z3))
|
||||
(global.set $global__2 (local.get $z4))
|
||||
(local.get $z1)
|
||||
)
|
||||
|
||||
)
|
||||
|
@ -64,17 +64,16 @@ object "D_16" {
|
||||
returndatacopy(_1, _1, returndatasize())
|
||||
revert(_1, returndatasize())
|
||||
}
|
||||
return(allocate_memory(_1), _1)
|
||||
return(allocate_memory(), _1)
|
||||
}
|
||||
}
|
||||
revert(0, 0)
|
||||
}
|
||||
function allocate_memory(size) -> memPtr
|
||||
function allocate_memory() -> memPtr
|
||||
{
|
||||
memPtr := mload(64)
|
||||
let newFreePtr := add(memPtr, and(add(size, 31), not(31)))
|
||||
if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() }
|
||||
mstore(64, newFreePtr)
|
||||
if gt(memPtr, 0xffffffffffffffff) { panic_error_0x41() }
|
||||
mstore(64, memPtr)
|
||||
}
|
||||
function panic_error_0x41()
|
||||
{
|
||||
|
@ -45,14 +45,14 @@ object "C_59" {
|
||||
for { } lt(i, _4) { i := add(i, 1) }
|
||||
{
|
||||
if slt(sub(calldatasize(), src), _2) { revert(_1, _1) }
|
||||
let value := allocate_memory(_2)
|
||||
let value := allocate_memory_1246()
|
||||
mstore(value, calldataload(src))
|
||||
mstore(dst, value)
|
||||
dst := add(dst, _2)
|
||||
src := add(src, _2)
|
||||
}
|
||||
let ret, ret_1 := fun_sumArray(dst_1)
|
||||
let memPos := allocate_memory(_1)
|
||||
let memPos := allocate_memory_1247()
|
||||
return(memPos, sub(abi_encode_uint256_string(memPos, ret, ret_1), memPos))
|
||||
}
|
||||
}
|
||||
@ -76,6 +76,19 @@ object "C_59" {
|
||||
}
|
||||
tail := add(add(headStart, and(add(length, 31), not(31))), 96)
|
||||
}
|
||||
function allocate_memory_1246() -> memPtr
|
||||
{
|
||||
memPtr := mload(64)
|
||||
let newFreePtr := add(memPtr, 32)
|
||||
if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() }
|
||||
mstore(64, newFreePtr)
|
||||
}
|
||||
function allocate_memory_1247() -> memPtr
|
||||
{
|
||||
memPtr := mload(64)
|
||||
if gt(memPtr, 0xffffffffffffffff) { panic_error_0x41() }
|
||||
mstore(64, memPtr)
|
||||
}
|
||||
function allocate_memory(size) -> memPtr
|
||||
{
|
||||
memPtr := mload(64)
|
||||
@ -85,7 +98,10 @@ object "C_59" {
|
||||
}
|
||||
function copy_literal_to_memory_64902fd228f7ef267f3b474dd6ef84bae434cf5546eee948e7ca26df3eda1927() -> memPtr
|
||||
{
|
||||
let memPtr_1 := allocate_memory(160)
|
||||
let memPtr_1 := mload(64)
|
||||
let newFreePtr := add(memPtr_1, 160)
|
||||
if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr_1)) { panic_error_0x41() }
|
||||
mstore(64, newFreePtr)
|
||||
mstore(memPtr_1, 100)
|
||||
memPtr := memPtr_1
|
||||
mstore(add(memPtr_1, 0x20), "longstringlongstringlongstringlo")
|
||||
@ -101,7 +117,7 @@ object "C_59" {
|
||||
{
|
||||
if iszero(lt(var_mpos, mload(var_s_mpos))) { panic_error_0x32() }
|
||||
let _1 := mload(mload(add(add(var_s_mpos, shl(5, var_mpos)), 32)))
|
||||
let _2, _3 := storage_array_index_access_struct_S(var_mpos, var_mpos)
|
||||
let _2, _3 := storage_array_index_access_struct_S_1254()
|
||||
sstore(_2, _1)
|
||||
if iszero(lt(0x01, mload(var_s_mpos))) { panic_error_0x32() }
|
||||
let _4 := mload(mload(add(var_s_mpos, 64)))
|
||||
@ -111,7 +127,7 @@ object "C_59" {
|
||||
let shiftBits := shl(3, var_mpos)
|
||||
let mask := shl(shiftBits, not(0))
|
||||
sstore(slot, or(and(_5, not(mask)), and(shl(shiftBits, _4), mask)))
|
||||
let _6, _7 := storage_array_index_access_struct_S(0x02, var_mpos)
|
||||
let _6, _7 := storage_array_index_access_struct_S()
|
||||
var := extract_from_storage_value_dynamict_uint256(sload(_6), _7)
|
||||
var_mpos := copy_literal_to_memory_64902fd228f7ef267f3b474dd6ef84bae434cf5546eee948e7ca26df3eda1927()
|
||||
}
|
||||
@ -127,10 +143,16 @@ object "C_59" {
|
||||
mstore(4, 0x41)
|
||||
revert(0, 0x24)
|
||||
}
|
||||
function storage_array_index_access_struct_S(array, index) -> slot, offset
|
||||
function storage_array_index_access_struct_S_1254() -> slot, offset
|
||||
{
|
||||
if iszero(lt(index, 0x02)) { panic_error_0x32() }
|
||||
slot := add(array, index)
|
||||
if iszero(lt(slot, 0x02)) { panic_error_0x32() }
|
||||
slot := add(slot, slot)
|
||||
offset := offset
|
||||
}
|
||||
function storage_array_index_access_struct_S() -> slot, offset
|
||||
{
|
||||
if iszero(lt(slot, 0x02)) { panic_error_0x32() }
|
||||
slot := add(0x02, slot)
|
||||
offset := offset
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ object "Arraysum_34" {
|
||||
mstore(_1, _1)
|
||||
var_sum := checked_add_uint256(var_sum, sload(add(keccak256(_1, 0x20), var_i)))
|
||||
}
|
||||
let memPos := allocate_memory(_1)
|
||||
let memPos := allocate_memory()
|
||||
return(memPos, sub(abi_encode_uint256(memPos, var_sum), memPos))
|
||||
}
|
||||
}
|
||||
@ -51,17 +51,16 @@ object "Arraysum_34" {
|
||||
tail := add(headStart, 32)
|
||||
mstore(headStart, value0)
|
||||
}
|
||||
function allocate_memory(size) -> memPtr
|
||||
function allocate_memory() -> memPtr
|
||||
{
|
||||
memPtr := mload(64)
|
||||
let newFreePtr := add(memPtr, and(add(size, 31), not(31)))
|
||||
if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr))
|
||||
if gt(memPtr, 0xffffffffffffffff)
|
||||
{
|
||||
mstore(0, shl(224, 0x4e487b71))
|
||||
mstore(4, 0x41)
|
||||
revert(0, 0x24)
|
||||
}
|
||||
mstore(64, newFreePtr)
|
||||
mstore(64, memPtr)
|
||||
}
|
||||
function checked_add_uint256(x, y) -> sum
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
{"contracts":{"A":{"C":{"ewasm":{"wasm":"0061736d01000000013f0960000060017e017e60047e7e7e7e017f60087e7e7e7e7e7e7e7e00600c7e7e7e7e7e7e7e7e7e7e7e7e0060017f0060017f017f60027f7f0060037f7f7f0002510408657468657265756d08636f6465436f7079000808657468657265756d06726576657274000708657468657265756d0c67657443616c6c56616c7565000508657468657265756d0666696e6973680007030a090002020606010403030503010001060100071102066d656d6f72790200046d61696e00040086030c435f335f6465706c6f7965640061736d0100000001160460000060047e7e7e7e017f60017f017f60027f7f0002130108657468657265756d067265766572740003030504000102020503010001060100071102066d656d6f72790200046d61696e00010a9f0204b30104017e027f037e037f02404200210020002000200042c00010022101200141c0006a210220022001490440000b2000a71004ad422086210320032000422088a71004ad84210420022004370000200241086a2004370000200241106a2004370000428001a71004ad4220862105200241186a2005428001422088a71004ad84370000200020002000200010022106200020002000200010022107200741c0006a210820082007490440000b2008200610000b0b2901017f024042002000200184200284520440000b42002003422088520440000b2003a721040b20040b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100341107421022002200041107610037221010b20010b0af00309dc0103017e027f057e02404200210020002000200042c00010052101200141c0006a210220022001490440000b20001009210320022003370000200241086a2003370000200241106a2003370000200241186a428001100937000041001002410029000010092104410041086a29000010092105410041106a2900001009210620042005842006410041186a290000100984845045044020002000200020002000200020002000100c0b42f9022107200020002000200020002000200042d3012000200020002007100a20002000200020002000200020002007100b0b0b2901017f024042002000200184200284520440000b42002003422088520440000b2003a721040b20040b2601027f0240200020012002200310052105200541c0006a210420042005490440000b0b20040b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100741107421022002200041107610077221010b20010b2201027e02402000a71008ad422086210220022000422088a71008ad8421010b20010b25000240200020012002200310062004200520062007100520082009200a200b100510000b0b1b000240200020012002200310062004200520062007100510030b0b1b000240200020012002200310062004200520062007100510010b0b","wast":"(module
|
||||
{"contracts":{"A":{"C":{"ewasm":{"wasm":"0061736d0100000001330b6000006000017e6000017f60017e0060017e017e60017e017f60027e7e0060017f0060017f017f60027f7f0060037f7f7f0002510408657468657265756d08636f6465436f7079000a08657468657265756d06726576657274000908657468657265756d0c67657443616c6c56616c7565000708657468657265756d0666696e6973680009030d0c0002050208080101040603000503010001060100071102066d656d6f72790200046d61696e00040092030c435f335f6465706c6f7965640061736d010000000112046000006000017f60017f017f60027f7f0002130108657468657265756d06726576657274000303060500010102020503010001060100071102066d656d6f72790200046d61696e00010aae02059d0103017e027f037e02404200210020002000200084200084520440000b200042c000422088520440000b42c000a72101200141c0006a210220022001490440000b2000a71005ad422086210320032000422088a71005ad84210420022004370000200241086a2004370000200241106a2004370000428001a71005ad4220862105200241186a2005428001422088a71005ad843700001003100210000b0b2f02017f017e02404200210120012001200184200184520440000b20012001422088520440000b2001a721000b20000b1e01027f024010022101200141c0006a210020002001490440000b0b20000b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100441107421022002200041107610047221010b20010b0aca040c960102027f057e024010052100200041c0006a210120012000490440000b100a210220012002370000200141086a2002370000200141106a2002370000200141186a100b370000410010024100290000100c2103410041086a290000100c2104410041106a290000100c210520032004842005410041186a290000100c848450450440100f0b428503210642ca012006100d2006100e0b0b2b01017f024042004200420084420084520440000b420042c000422088520440000b42c000a721000b20000b2901017f024042004200420084420084520440000b42002000422088520440000b2000a721010b20010b2f02017f017e02404200210120012001200184200184520440000b20012001422088520440000b2001a721000b20000b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100841107421022002200041107610087221010b20010b2201027e02404200a71009ad422086210120014200422088a71009ad8421000b20000b2401027e0240428001a71009ad42208621012001428001422088a71009ad8421000b20000b2201027e02402000a71009ad422086210220022000422088a71009ad8421010b20010b3001047f024020011006210220001006210310072104200441c0006a210520052004490440000b20052003200210000b0b2801037f024020001006210110072102200241c0006a210320032002490440000b2003200110030b0b2601037f02401007210010072101200141c0006a210220022001490440000b2002200010010b0b","wast":"(module
|
||||
;; custom section for sub-module
|
||||
;; The Keccak-256 hash of the text representation of \"C_3_deployed\": 380167268971b84f9fd4e61f1659da4fd304bd6e30ec2dd33d412f3c8203ced7
|
||||
;; (@custom \"C_3_deployed\" \"0061736d0100000001160460000060047e7e7e7e017f60017f017f60027f7f0002130108657468657265756d067265766572740003030504000102020503010001060100071102066d656d6f72790200046d61696e00010a9f0204b30104017e027f037e037f02404200210020002000200042c00010022101200141c0006a210220022001490440000b2000a71004ad422086210320032000422088a71004ad84210420022004370000200241086a2004370000200241106a2004370000428001a71004ad4220862105200241186a2005428001422088a71004ad84370000200020002000200010022106200020002000200010022107200741c0006a210820082007490440000b2008200610000b0b2901017f024042002000200184200284520440000b42002003422088520440000b2003a721040b20040b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100341107421022002200041107610037221010b20010b\")
|
||||
;; The Keccak-256 hash of the text representation of \"C_3_deployed\": 1c21519afc0397d3ba45d99eb2354c3d74191cd82bffab348d52efabddb63f6a
|
||||
;; (@custom \"C_3_deployed\" \"0061736d010000000112046000006000017f60017f017f60027f7f0002130108657468657265756d06726576657274000303060500010102020503010001060100071102066d656d6f72790200046d61696e00010aae02059d0103017e027f037e02404200210020002000200084200084520440000b200042c000422088520440000b42c000a72101200141c0006a210220022001490440000b2000a71005ad422086210320032000422088a71005ad84210420022004370000200241086a2004370000200241106a2004370000428001a71005ad4220862105200241186a2005428001422088a71005ad843700001003100210000b0b2f02017f017e02404200210120012001200184200184520440000b20012001422088520440000b2001a721000b20000b1e01027f024010022101200141c0006a210020002001490440000b0b20000b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100441107421022002200041107610047221010b20010b\")
|
||||
(import \"ethereum\" \"codeCopy\" (func $eth.codeCopy (param i32 i32 i32)))
|
||||
(import \"ethereum\" \"revert\" (func $eth.revert (param i32 i32)))
|
||||
(import \"ethereum\" \"getCallValue\" (func $eth.getCallValue (param i32)))
|
||||
@ -10,46 +10,55 @@
|
||||
(export \"main\" (func $main))
|
||||
|
||||
(func $main
|
||||
(local $_1 i64)
|
||||
(local $p i32)
|
||||
(local $r i32)
|
||||
(local $_2 i64)
|
||||
(local $_1 i64)
|
||||
(local $z1 i64)
|
||||
(local $z2 i64)
|
||||
(local $z3 i64)
|
||||
(local $_3 i64)
|
||||
(local $_2 i64)
|
||||
(block $label_
|
||||
(local.set $_1 (i64.const 0))
|
||||
(local.set $p (call $u256_to_i32 (local.get $_1) (local.get $_1) (local.get $_1) (i64.const 64)))
|
||||
(local.set $p (call $u256_to_i32_685))
|
||||
(local.set $r (i32.add (local.get $p) (i32.const 64)))
|
||||
(if (i32.lt_u (local.get $r) (local.get $p)) (then
|
||||
(unreachable)))
|
||||
(local.set $_2 (call $bswap64 (local.get $_1)))
|
||||
(i64.store (local.get $r) (local.get $_2))
|
||||
(i64.store (i32.add (local.get $r) (i32.const 8)) (local.get $_2))
|
||||
(i64.store (i32.add (local.get $r) (i32.const 16)) (local.get $_2))
|
||||
(i64.store (i32.add (local.get $r) (i32.const 24)) (call $bswap64 (i64.const 128)))
|
||||
(local.set $_1 (call $bswap64_388))
|
||||
(i64.store (local.get $r) (local.get $_1))
|
||||
(i64.store (i32.add (local.get $r) (i32.const 8)) (local.get $_1))
|
||||
(i64.store (i32.add (local.get $r) (i32.const 16)) (local.get $_1))
|
||||
(i64.store (i32.add (local.get $r) (i32.const 24)) (call $bswap64_389))
|
||||
(call $eth.getCallValue (i32.const 0))
|
||||
(local.set $z1 (call $bswap64 (i64.load (i32.const 0))))
|
||||
(local.set $z2 (call $bswap64 (i64.load (i32.add (i32.const 0) (i32.const 8)))))
|
||||
(local.set $z3 (call $bswap64 (i64.load (i32.add (i32.const 0) (i32.const 16)))))
|
||||
(if (i32.eqz (i64.eqz (i64.or (i64.or (local.get $z1) (local.get $z2)) (i64.or (local.get $z3) (call $bswap64 (i64.load (i32.add (i32.const 0) (i32.const 24)))))))) (then
|
||||
(call $revert (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1))))
|
||||
(local.set $_3 (datasize \"C_3_deployed\"))
|
||||
(call $codecopy (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1) (dataoffset \"C_3_deployed\") (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_3))
|
||||
(call $return (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_3))
|
||||
(call $revert)))
|
||||
(local.set $_2 (datasize \"C_3_deployed\"))
|
||||
(call $codecopy (dataoffset \"C_3_deployed\") (local.get $_2))
|
||||
(call $return (local.get $_2))
|
||||
)
|
||||
)
|
||||
|
||||
(func $u256_to_i32
|
||||
(param $x1 i64)
|
||||
(param $x2 i64)
|
||||
(param $x3 i64)
|
||||
(param $x4 i64)
|
||||
(func $u256_to_i32_685
|
||||
(result i32)
|
||||
(local $v i32)
|
||||
(block $label__1
|
||||
(if (i64.ne (i64.const 0) (i64.or (i64.or (local.get $x1) (local.get $x2)) (local.get $x3))) (then
|
||||
(if (i64.ne (i64.const 0) (i64.or (i64.or (i64.const 0) (i64.const 0)) (i64.const 0))) (then
|
||||
(unreachable)))
|
||||
(if (i64.ne (i64.const 0) (i64.shr_u (i64.const 64) (i64.const 32))) (then
|
||||
(unreachable)))
|
||||
(local.set $v (i32.wrap_i64 (i64.const 64)))
|
||||
|
||||
)
|
||||
(local.get $v)
|
||||
)
|
||||
|
||||
(func $u256_to_i32_687
|
||||
(param $x4 i64)
|
||||
(result i32)
|
||||
(local $v i32)
|
||||
(block $label__2
|
||||
(if (i64.ne (i64.const 0) (i64.or (i64.or (i64.const 0) (i64.const 0)) (i64.const 0))) (then
|
||||
(unreachable)))
|
||||
(if (i64.ne (i64.const 0) (i64.shr_u (local.get $x4) (i64.const 32))) (then
|
||||
(unreachable)))
|
||||
@ -59,29 +68,27 @@
|
||||
(local.get $v)
|
||||
)
|
||||
|
||||
(func $to_internal_i32ptr
|
||||
(param $x1 i64)
|
||||
(param $x2 i64)
|
||||
(param $x3 i64)
|
||||
(param $x4 i64)
|
||||
(func $u256_to_i32
|
||||
(result i32)
|
||||
(local $r i32)
|
||||
(local $p i32)
|
||||
(block $label__2
|
||||
(local.set $p (call $u256_to_i32 (local.get $x1) (local.get $x2) (local.get $x3) (local.get $x4)))
|
||||
(local.set $r (i32.add (local.get $p) (i32.const 64)))
|
||||
(if (i32.lt_u (local.get $r) (local.get $p)) (then
|
||||
(local $v i32)
|
||||
(local $_1 i64)
|
||||
(block $label__3
|
||||
(local.set $_1 (i64.const 0))
|
||||
(if (i64.ne (local.get $_1) (i64.or (i64.or (local.get $_1) (local.get $_1)) (local.get $_1))) (then
|
||||
(unreachable)))
|
||||
(if (i64.ne (local.get $_1) (i64.shr_u (local.get $_1) (i64.const 32))) (then
|
||||
(unreachable)))
|
||||
(local.set $v (i32.wrap_i64 (local.get $_1)))
|
||||
|
||||
)
|
||||
(local.get $r)
|
||||
(local.get $v)
|
||||
)
|
||||
|
||||
(func $bswap16
|
||||
(param $x i32)
|
||||
(result i32)
|
||||
(local $y i32)
|
||||
(block $label__3
|
||||
(block $label__4
|
||||
(local.set $y (i32.or (i32.and (i32.shl (local.get $x) (i32.const 8)) (i32.const 65280)) (i32.and (i32.shr_u (local.get $x) (i32.const 8)) (i32.const 255))))
|
||||
|
||||
)
|
||||
@ -93,7 +100,7 @@
|
||||
(result i32)
|
||||
(local $y i32)
|
||||
(local $hi i32)
|
||||
(block $label__4
|
||||
(block $label__5
|
||||
(local.set $hi (i32.shl (call $bswap16 (local.get $x)) (i32.const 16)))
|
||||
(local.set $y (i32.or (local.get $hi) (call $bswap16 (i32.shr_u (local.get $x) (i32.const 16)))))
|
||||
|
||||
@ -101,12 +108,36 @@
|
||||
(local.get $y)
|
||||
)
|
||||
|
||||
(func $bswap64_388
|
||||
(result i64)
|
||||
(local $y i64)
|
||||
(local $hi i64)
|
||||
(block $label__6
|
||||
(local.set $hi (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.const 0)))) (i64.const 32)))
|
||||
(local.set $y (i64.or (local.get $hi) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (i64.const 0) (i64.const 32)))))))
|
||||
|
||||
)
|
||||
(local.get $y)
|
||||
)
|
||||
|
||||
(func $bswap64_389
|
||||
(result i64)
|
||||
(local $y i64)
|
||||
(local $hi i64)
|
||||
(block $label__7
|
||||
(local.set $hi (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.const 128)))) (i64.const 32)))
|
||||
(local.set $y (i64.or (local.get $hi) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (i64.const 128) (i64.const 32)))))))
|
||||
|
||||
)
|
||||
(local.get $y)
|
||||
)
|
||||
|
||||
(func $bswap64
|
||||
(param $x i64)
|
||||
(result i64)
|
||||
(local $y i64)
|
||||
(local $hi i64)
|
||||
(block $label__5
|
||||
(block $label__8
|
||||
(local.set $hi (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (local.get $x)))) (i64.const 32)))
|
||||
(local.set $y (i64.or (local.get $hi) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (local.get $x) (i64.const 32)))))))
|
||||
|
||||
@ -115,48 +146,49 @@
|
||||
)
|
||||
|
||||
(func $codecopy
|
||||
(param $x1 i64)
|
||||
(param $x2 i64)
|
||||
(param $x3 i64)
|
||||
(param $x4 i64)
|
||||
(param $y1 i64)
|
||||
(param $y2 i64)
|
||||
(param $y3 i64)
|
||||
(param $y4 i64)
|
||||
(param $z1 i64)
|
||||
(param $z2 i64)
|
||||
(param $z3 i64)
|
||||
(param $z4 i64)
|
||||
(block $label__6
|
||||
(call $eth.codeCopy (call $to_internal_i32ptr (local.get $x1) (local.get $x2) (local.get $x3) (local.get $x4)) (call $u256_to_i32 (local.get $y1) (local.get $y2) (local.get $y3) (local.get $y4)) (call $u256_to_i32 (local.get $z1) (local.get $z2) (local.get $z3) (local.get $z4)))
|
||||
(local $_1 i32)
|
||||
(local $_2 i32)
|
||||
(local $p i32)
|
||||
(local $r i32)
|
||||
(block $label__9
|
||||
(local.set $_1 (call $u256_to_i32_687 (local.get $z4)))
|
||||
(local.set $_2 (call $u256_to_i32_687 (local.get $y4)))
|
||||
(local.set $p (call $u256_to_i32))
|
||||
(local.set $r (i32.add (local.get $p) (i32.const 64)))
|
||||
(if (i32.lt_u (local.get $r) (local.get $p)) (then
|
||||
(unreachable)))
|
||||
(call $eth.codeCopy (local.get $r) (local.get $_2) (local.get $_1))
|
||||
)
|
||||
)
|
||||
|
||||
(func $return
|
||||
(param $x1 i64)
|
||||
(param $x2 i64)
|
||||
(param $x3 i64)
|
||||
(param $x4 i64)
|
||||
(param $y1 i64)
|
||||
(param $y2 i64)
|
||||
(param $y3 i64)
|
||||
(param $y4 i64)
|
||||
(block $label__7
|
||||
(call $eth.finish (call $to_internal_i32ptr (local.get $x1) (local.get $x2) (local.get $x3) (local.get $x4)) (call $u256_to_i32 (local.get $y1) (local.get $y2) (local.get $y3) (local.get $y4)))
|
||||
(local $_1 i32)
|
||||
(local $p i32)
|
||||
(local $r i32)
|
||||
(block $label__10
|
||||
(local.set $_1 (call $u256_to_i32_687 (local.get $y4)))
|
||||
(local.set $p (call $u256_to_i32))
|
||||
(local.set $r (i32.add (local.get $p) (i32.const 64)))
|
||||
(if (i32.lt_u (local.get $r) (local.get $p)) (then
|
||||
(unreachable)))
|
||||
(call $eth.finish (local.get $r) (local.get $_1))
|
||||
)
|
||||
)
|
||||
|
||||
(func $revert
|
||||
(param $x1 i64)
|
||||
(param $x2 i64)
|
||||
(param $x3 i64)
|
||||
(param $x4 i64)
|
||||
(param $y1 i64)
|
||||
(param $y2 i64)
|
||||
(param $y3 i64)
|
||||
(param $y4 i64)
|
||||
(block $label__8
|
||||
(call $eth.revert (call $to_internal_i32ptr (local.get $x1) (local.get $x2) (local.get $x3) (local.get $x4)) (call $u256_to_i32 (local.get $y1) (local.get $y2) (local.get $y3) (local.get $y4)))
|
||||
(local $_1 i32)
|
||||
(local $p i32)
|
||||
(local $r i32)
|
||||
(block $label__11
|
||||
(local.set $_1 (call $u256_to_i32))
|
||||
(local.set $p (call $u256_to_i32))
|
||||
(local.set $r (i32.add (local.get $p) (i32.const 64)))
|
||||
(if (i32.lt_u (local.get $r) (local.get $p)) (then
|
||||
(unreachable)))
|
||||
(call $eth.revert (local.get $r) (local.get $_1))
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -35,9 +35,9 @@ object "C_3" {
|
||||
|
||||
======= viair_subobjects/input.sol:D =======
|
||||
Binary:
|
||||
608060405234156100105760006000fd5b61010d80610021600039806000f350fe6080604052600436101515610088576000803560e01c6326121ff0141561008657341561002a578081fd5b806003193601121561003a578081fd5b6028806080016080811067ffffffffffffffff8211171561005e5761005d6100cb565b5b50806100e560803980608083f01515610079573d82833e3d82fd5b508061008482610092565bf35b505b60006000fd6100e3565b60006040519050601f19601f830116810181811067ffffffffffffffff821117156100c0576100bf6100cb565b5b80604052505b919050565b634e487b7160e01b600052604160045260246000fd5b565bfe60806040523415600f5760006000fd5b600a80601e600039806000f350fe608060405260006000fd
|
||||
608060405234156100105760006000fd5b60fb80610020600039806000f350fe6080604052600436101515610087576000803560e01c6326121ff0141561008557341561002a578081fd5b806003193601121561003a578081fd5b6028806080016080811067ffffffffffffffff8211171561005e5761005d6100b9565b5b50806100d360803980608083f01515610079573d82833e3d82fd5b5080610083610091565bf35b505b60006000fd6100d1565b6000604051905067ffffffffffffffff8111156100b1576100b06100b9565b5b806040525b90565b634e487b7160e01b600052604160045260246000fd5b565bfe60806040523415600f5760006000fd5b600a80601e600039806000f350fe608060405260006000fd
|
||||
Binary of the runtime part:
|
||||
6080604052600436101515610088576000803560e01c6326121ff0141561008657341561002a578081fd5b806003193601121561003a578081fd5b6028806080016080811067ffffffffffffffff8211171561005e5761005d6100cb565b5b50806100e560803980608083f01515610079573d82833e3d82fd5b508061008482610092565bf35b505b60006000fd6100e3565b60006040519050601f19601f830116810181811067ffffffffffffffff821117156100c0576100bf6100cb565b5b80604052505b919050565b634e487b7160e01b600052604160045260246000fd5b565bfe60806040523415600f5760006000fd5b600a80601e600039806000f350fe608060405260006000fd
|
||||
6080604052600436101515610087576000803560e01c6326121ff0141561008557341561002a578081fd5b806003193601121561003a578081fd5b6028806080016080811067ffffffffffffffff8211171561005e5761005d6100b9565b5b50806100d360803980608083f01515610079573d82833e3d82fd5b5080610083610091565bf35b505b60006000fd6100d1565b6000604051905067ffffffffffffffff8111156100b1576100b06100b9565b5b806040525b90565b634e487b7160e01b600052604160045260246000fd5b565bfe60806040523415600f5760006000fd5b600a80601e600039806000f350fe608060405260006000fd
|
||||
Optimized IR:
|
||||
/*******************************************************
|
||||
* WARNING *
|
||||
@ -76,17 +76,16 @@ object "D_16" {
|
||||
returndatacopy(_1, _1, returndatasize())
|
||||
revert(_1, returndatasize())
|
||||
}
|
||||
return(allocate_memory(_1), _1)
|
||||
return(allocate_memory(), _1)
|
||||
}
|
||||
}
|
||||
revert(0, 0)
|
||||
}
|
||||
function allocate_memory(size) -> memPtr
|
||||
function allocate_memory() -> memPtr
|
||||
{
|
||||
memPtr := mload(64)
|
||||
let newFreePtr := add(memPtr, and(add(size, 31), not(31)))
|
||||
if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() }
|
||||
mstore(64, newFreePtr)
|
||||
if gt(memPtr, 0xffffffffffffffff) { panic_error_0x41() }
|
||||
mstore(64, memPtr)
|
||||
}
|
||||
function panic_error_0x41()
|
||||
{
|
||||
|
@ -17,9 +17,9 @@ contract C {
|
||||
// optimize-yul: true
|
||||
// ----
|
||||
// creation:
|
||||
// codeDepositCost: 571400
|
||||
// executionCost: 606
|
||||
// totalCost: 572006
|
||||
// codeDepositCost: 626600
|
||||
// executionCost: 657
|
||||
// totalCost: 627257
|
||||
// external:
|
||||
// a(): 985
|
||||
// b(uint256): 2052
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <libyul/optimiser/ExpressionSplitter.h>
|
||||
#include <libyul/optimiser/FunctionGrouper.h>
|
||||
#include <libyul/optimiser/FunctionHoister.h>
|
||||
#include <libyul/optimiser/FunctionSpecializer.h>
|
||||
#include <libyul/optimiser/ExpressionInliner.h>
|
||||
#include <libyul/optimiser/FullInliner.h>
|
||||
#include <libyul/optimiser/ForLoopConditionIntoBody.h>
|
||||
@ -151,6 +152,11 @@ YulOptimizerTestCommon::YulOptimizerTestCommon(
|
||||
disambiguate();
|
||||
FunctionHoister::run(*m_context, *m_ast);
|
||||
}},
|
||||
{"functionSpecializer", [&]() {
|
||||
disambiguate();
|
||||
FunctionHoister::run(*m_context, *m_object->code);
|
||||
FunctionSpecializer::run(*m_context, *m_object->code);
|
||||
}},
|
||||
{"expressionInliner", [&]() {
|
||||
disambiguate();
|
||||
ExpressionInliner::run(*m_context, *m_ast);
|
||||
|
@ -507,12 +507,11 @@
|
||||
// for { } lt(i, length) { i := add(i, 1) }
|
||||
// {
|
||||
// if iszero(slt(add(src, _1), end)) { revert(0, 0) }
|
||||
// let _3 := 64
|
||||
// let dst_1 := allocateMemory(_3)
|
||||
// let dst_1 := allocateMemory_967()
|
||||
// let dst_2 := dst_1
|
||||
// let src_1 := src
|
||||
// let _4 := add(src, _3)
|
||||
// if gt(_4, end) { revert(0, 0) }
|
||||
// let _3 := add(src, 64)
|
||||
// if gt(_3, end) { revert(0, 0) }
|
||||
// let i_1 := 0
|
||||
// for { } lt(i_1, 0x2) { i_1 := add(i_1, 1) }
|
||||
// {
|
||||
@ -522,7 +521,7 @@
|
||||
// }
|
||||
// mstore(dst, dst_2)
|
||||
// dst := add(dst, _2)
|
||||
// src := _4
|
||||
// src := _3
|
||||
// }
|
||||
// }
|
||||
// function abi_decode_uint256t_uint256t_array_uint256_dynt_array_array_uint256_memory_dyn(headStart, dataEnd) -> value0, value1, value2, value3
|
||||
@ -555,6 +554,13 @@
|
||||
// if gt(offset_1, _2) { revert(value3, value3) }
|
||||
// value3 := abi_decode_array_array_uint256_memory_dyn(add(headStart, offset_1), dataEnd)
|
||||
// }
|
||||
// function allocateMemory_967() -> memPtr
|
||||
// {
|
||||
// memPtr := mload(64)
|
||||
// let newFreePtr := add(memPtr, 64)
|
||||
// if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { revert(0, 0) }
|
||||
// mstore(64, newFreePtr)
|
||||
// }
|
||||
// function allocateMemory(size) -> memPtr
|
||||
// {
|
||||
// memPtr := mload(64)
|
||||
|
555
test/libyul/yulOptimizerTests/fullSuite/ackermann_function.yul
Normal file
555
test/libyul/yulOptimizerTests/fullSuite/ackermann_function.yul
Normal file
@ -0,0 +1,555 @@
|
||||
// https://en.wikipedia.org/wiki/Ackermann_function
|
||||
// Test to see how FunctionSpecializer deals with functions that are too recursive / resource intensive.
|
||||
{
|
||||
// 5
|
||||
sstore(0, A(2, 1))
|
||||
// 7
|
||||
sstore(1, A(2, 2))
|
||||
|
||||
// Too many unrolling needed. In arbitrary precision, the value is 2**65536 - 3.
|
||||
sstore(2, A(4, 2))
|
||||
|
||||
function A(m, n) -> ret {
|
||||
switch m
|
||||
case 0 { ret := add(n, 1) }
|
||||
default {
|
||||
switch n
|
||||
case 0 { ret := A(sub(m, 1), 1) }
|
||||
default { ret := A(sub(m, 1), A(m, sub(n, 1))) }
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// step: fullSuite
|
||||
//
|
||||
// {
|
||||
// {
|
||||
// sstore(0, 5)
|
||||
// sstore(1, add(2, 5))
|
||||
// let _1 := not(0)
|
||||
// let _2 := A_985(A_4878(A_4886(add(5, _1))))
|
||||
// let ret := 0
|
||||
// switch _2
|
||||
// case 0 { ret := 5 }
|
||||
// default {
|
||||
// let _3 := A_985(add(_2, _1))
|
||||
// let ret_1 := 0
|
||||
// switch _3
|
||||
// case 0 { ret_1 := 3 }
|
||||
// default {
|
||||
// ret_1 := A_2511(A_2505(add(_3, _1)))
|
||||
// }
|
||||
// ret := ret_1
|
||||
// }
|
||||
// sstore(2, ret)
|
||||
// }
|
||||
// function A_20862() -> ret
|
||||
// {
|
||||
// switch 1
|
||||
// case 0 { ret := add(ret, 1) }
|
||||
// default {
|
||||
// let _1 := add(1, not(0))
|
||||
// let ret_1 := 0
|
||||
// switch _1
|
||||
// case 0 { ret_1 := 2 }
|
||||
// default {
|
||||
// ret_1 := A(add(1, not(1)), A_294(_1))
|
||||
// }
|
||||
// ret := ret_1
|
||||
// }
|
||||
// }
|
||||
// function A_20864() -> ret
|
||||
// {
|
||||
// switch 2
|
||||
// case 0 { ret := add(ret, 1) }
|
||||
// default {
|
||||
// let _1 := add(2, not(0))
|
||||
// let ret_1 := 0
|
||||
// switch _1
|
||||
// case 0 { ret_1 := 2 }
|
||||
// default {
|
||||
// ret_1 := A(add(2, not(1)), A_294(_1))
|
||||
// }
|
||||
// ret := ret_1
|
||||
// }
|
||||
// }
|
||||
// function A_20874() -> ret
|
||||
// {
|
||||
// switch 1
|
||||
// case 0 { ret := add(ret, 1) }
|
||||
// default {
|
||||
// let _1 := add(1, not(0))
|
||||
// let ret_1 := 0
|
||||
// switch _1
|
||||
// case 0 { ret_1 := 2 }
|
||||
// default {
|
||||
// ret_1 := A(add(1, not(1)), A_294(_1))
|
||||
// }
|
||||
// ret := ret_1
|
||||
// }
|
||||
// }
|
||||
// function A_294(m) -> ret
|
||||
// {
|
||||
// switch m
|
||||
// case 0 { ret := add(ret, 1) }
|
||||
// default {
|
||||
// let _1 := add(m, not(0))
|
||||
// let ret_1 := 0
|
||||
// switch _1
|
||||
// case 0 { ret_1 := 2 }
|
||||
// default {
|
||||
// ret_1 := A(add(m, not(1)), A_294(_1))
|
||||
// }
|
||||
// ret := ret_1
|
||||
// }
|
||||
// }
|
||||
// function A_985(n) -> ret
|
||||
// {
|
||||
// switch n
|
||||
// case 0 { ret := 5 }
|
||||
// default {
|
||||
// let ret_1 := 0
|
||||
// switch add(n, not(0))
|
||||
// case 0 { ret_1 := 5 }
|
||||
// default {
|
||||
// let ret_2 := 0
|
||||
// switch add(n, not(1))
|
||||
// case 0 { ret_2 := add(2, 3) }
|
||||
// default {
|
||||
// let ret_3 := 0
|
||||
// switch add(n, not(2))
|
||||
// case 0 {
|
||||
// ret_3 := add(A_13949(A_13949(A_20856())), 1)
|
||||
// }
|
||||
// default {
|
||||
// let ret_4 := 0
|
||||
// switch add(n, not(3))
|
||||
// case 0 { ret_4 := add(A_20857(), 1) }
|
||||
// default {
|
||||
// let ret_5 := 0
|
||||
// switch add(n, not(4))
|
||||
// case 0 { ret_5 := A_20858() }
|
||||
// default {
|
||||
// ret_5 := A_13953(A_13952(add(n, not(5))))
|
||||
// }
|
||||
// ret_4 := A_11648(ret_5)
|
||||
// }
|
||||
// ret_3 := A_9730(ret_4)
|
||||
// }
|
||||
// ret_2 := A_7274(ret_3)
|
||||
// }
|
||||
// ret_1 := A_4886(ret_2)
|
||||
// }
|
||||
// ret := A_2505(ret_1)
|
||||
// }
|
||||
// }
|
||||
// function A_2505(n) -> ret
|
||||
// {
|
||||
// switch n
|
||||
// case 0 { ret := 3 }
|
||||
// default {
|
||||
// ret := A_4878(A_4886(add(n, not(0))))
|
||||
// }
|
||||
// }
|
||||
// function A_2511(n) -> ret
|
||||
// {
|
||||
// switch n
|
||||
// case 0 { ret := 2 }
|
||||
// default {
|
||||
// ret := add(A_4878(add(n, not(0))), 1)
|
||||
// }
|
||||
// }
|
||||
// function A_4878(n) -> ret
|
||||
// {
|
||||
// switch n
|
||||
// case 0 { ret := 2 }
|
||||
// default {
|
||||
// ret := add(A_7272(add(n, not(0))), 1)
|
||||
// }
|
||||
// }
|
||||
// function A_4886(n) -> ret
|
||||
// {
|
||||
// switch n
|
||||
// case 0 { ret := 3 }
|
||||
// default {
|
||||
// ret := A_7272(A_7274(add(n, not(0))))
|
||||
// }
|
||||
// }
|
||||
// function A_7272(n) -> ret
|
||||
// {
|
||||
// switch n
|
||||
// case 0 { ret := 2 }
|
||||
// default {
|
||||
// ret := add(A_9725(add(n, not(0))), 1)
|
||||
// }
|
||||
// }
|
||||
// function A_7274(n) -> ret
|
||||
// {
|
||||
// switch n
|
||||
// case 0 { ret := 3 }
|
||||
// default {
|
||||
// ret := A_9725(A_9730(add(n, not(0))))
|
||||
// }
|
||||
// }
|
||||
// function A_9725(n) -> ret
|
||||
// {
|
||||
// switch n
|
||||
// case 0 { ret := 2 }
|
||||
// default {
|
||||
// ret := add(A_11646(add(n, not(0))), 1)
|
||||
// }
|
||||
// }
|
||||
// function A_9730(n) -> ret
|
||||
// {
|
||||
// switch n
|
||||
// case 0 { ret := 3 }
|
||||
// default {
|
||||
// ret := A_11646(A_11648(add(n, not(0))))
|
||||
// }
|
||||
// }
|
||||
// function A_11646(n) -> ret
|
||||
// {
|
||||
// switch n
|
||||
// case 0 { ret := 2 }
|
||||
// default {
|
||||
// ret := add(A_13951(add(n, not(0))), 1)
|
||||
// }
|
||||
// }
|
||||
// function A_11648(n) -> ret
|
||||
// {
|
||||
// switch n
|
||||
// case 0 { ret := 3 }
|
||||
// default {
|
||||
// ret := A_13951(A_13953(add(n, not(0))))
|
||||
// }
|
||||
// }
|
||||
// function A_13949(n) -> ret
|
||||
// { ret := add(n, 1) }
|
||||
// function A_20857() -> ret
|
||||
// {
|
||||
// switch 2
|
||||
// case 0 { ret := 2 }
|
||||
// default {
|
||||
// ret := add(A_16299(add(2, not(0))), 1)
|
||||
// }
|
||||
// }
|
||||
// function A_20858() -> ret
|
||||
// {
|
||||
// switch 3
|
||||
// case 0 { ret := 2 }
|
||||
// default {
|
||||
// ret := add(A_16299(add(3, not(0))), 1)
|
||||
// }
|
||||
// }
|
||||
// function A_13951(n) -> ret
|
||||
// {
|
||||
// switch n
|
||||
// case 0 { ret := 2 }
|
||||
// default {
|
||||
// ret := add(A_16299(add(n, not(0))), 1)
|
||||
// }
|
||||
// }
|
||||
// function A_13952(n) -> ret
|
||||
// {
|
||||
// switch n
|
||||
// case 0 { ret := A_20861() }
|
||||
// default {
|
||||
// let ret_1 := 0
|
||||
// switch add(n, not(0))
|
||||
// case 0 {
|
||||
// ret_1 := A_18381(A_20863(A_20862()))
|
||||
// }
|
||||
// default {
|
||||
// let ret_2 := 0
|
||||
// switch add(n, not(1))
|
||||
// case 0 { ret_2 := A_20865(A_20864()) }
|
||||
// default {
|
||||
// ret_2 := A_20867(A_20866(add(n, not(2))))
|
||||
// }
|
||||
// ret_1 := A_18383(ret_2)
|
||||
// }
|
||||
// ret := A_16304(ret_1)
|
||||
// }
|
||||
// }
|
||||
// function A_13953(n) -> ret
|
||||
// {
|
||||
// switch n
|
||||
// case 0 { ret := 3 }
|
||||
// default {
|
||||
// ret := A_16299(A_16304(add(n, not(0))))
|
||||
// }
|
||||
// }
|
||||
// function A_20856() -> ret
|
||||
// {
|
||||
// switch ret
|
||||
// case 0 { ret := 2 }
|
||||
// default {
|
||||
// ret := add(A_18381(add(0, not(0))), 1)
|
||||
// }
|
||||
// }
|
||||
// function A_20861() -> ret
|
||||
// {
|
||||
// switch 3
|
||||
// case 0 { ret := 2 }
|
||||
// default {
|
||||
// ret := add(A_18381(add(3, not(0))), 1)
|
||||
// }
|
||||
// }
|
||||
// function A_16299(n) -> ret
|
||||
// {
|
||||
// switch n
|
||||
// case 0 { ret := 2 }
|
||||
// default {
|
||||
// ret := add(A_18381(add(n, not(0))), 1)
|
||||
// }
|
||||
// }
|
||||
// function A_16304(n) -> ret
|
||||
// {
|
||||
// switch n
|
||||
// case 0 { ret := 3 }
|
||||
// default {
|
||||
// ret := A_18381(A_18383(add(n, not(0))))
|
||||
// }
|
||||
// }
|
||||
// function A_18381(n) -> ret
|
||||
// {
|
||||
// switch n
|
||||
// case 0 { ret := 2 }
|
||||
// default {
|
||||
// ret := A_20869(A_20868(add(n, not(0))))
|
||||
// }
|
||||
// }
|
||||
// function A_18383(n) -> ret
|
||||
// {
|
||||
// switch n
|
||||
// case 0 { ret := A_20875(A_20874()) }
|
||||
// default {
|
||||
// ret := A_20877(A_20876(add(n, not(0))))
|
||||
// }
|
||||
// }
|
||||
// function A_20863(n) -> ret
|
||||
// {
|
||||
// switch ret
|
||||
// case 0 { ret := add(n, 1) }
|
||||
// default {
|
||||
// switch n
|
||||
// case 0 {
|
||||
// let _1 := add(0, not(0))
|
||||
// let ret_1 := 0
|
||||
// switch _1
|
||||
// case 0 { ret_1 := 2 }
|
||||
// default {
|
||||
// ret_1 := A(add(0, not(1)), A_294(_1))
|
||||
// }
|
||||
// ret := ret_1
|
||||
// }
|
||||
// default {
|
||||
// let _2 := not(0)
|
||||
// ret := A(add(0, _2), A(0, add(n, _2)))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// function A_20865(n) -> ret
|
||||
// {
|
||||
// let m := 1
|
||||
// switch m
|
||||
// case 0 { ret := add(n, m) }
|
||||
// default {
|
||||
// switch n
|
||||
// case 0 {
|
||||
// let _1 := add(m, not(0))
|
||||
// let ret_1 := 0
|
||||
// switch _1
|
||||
// case 0 { ret_1 := 2 }
|
||||
// default {
|
||||
// ret_1 := A(add(m, not(1)), A_294(_1))
|
||||
// }
|
||||
// ret := ret_1
|
||||
// }
|
||||
// default {
|
||||
// let _2 := not(0)
|
||||
// ret := A(add(m, _2), A(m, add(n, _2)))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// function A_20866(n) -> ret
|
||||
// {
|
||||
// switch 3
|
||||
// case 0 { ret := add(n, 1) }
|
||||
// default {
|
||||
// switch n
|
||||
// case 0 {
|
||||
// let _1 := add(3, not(0))
|
||||
// let ret_1 := 0
|
||||
// switch _1
|
||||
// case 0 { ret_1 := 2 }
|
||||
// default {
|
||||
// ret_1 := A(add(3, not(1)), A_294(_1))
|
||||
// }
|
||||
// ret := ret_1
|
||||
// }
|
||||
// default {
|
||||
// let _2 := not(0)
|
||||
// ret := A(add(3, _2), A(3, add(n, _2)))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// function A_20867(n) -> ret
|
||||
// {
|
||||
// let m := 2
|
||||
// switch m
|
||||
// case 0 { ret := add(n, 1) }
|
||||
// default {
|
||||
// switch n
|
||||
// case 0 {
|
||||
// let _1 := add(m, not(0))
|
||||
// let ret_1 := 0
|
||||
// switch _1
|
||||
// case 0 { ret_1 := m }
|
||||
// default {
|
||||
// ret_1 := A(add(m, not(1)), A_294(_1))
|
||||
// }
|
||||
// ret := ret_1
|
||||
// }
|
||||
// default {
|
||||
// let _2 := not(0)
|
||||
// ret := A(add(m, _2), A(m, add(n, _2)))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// function A_20868(n) -> ret
|
||||
// {
|
||||
// let m := 1
|
||||
// switch m
|
||||
// case 0 { ret := add(n, m) }
|
||||
// default {
|
||||
// switch n
|
||||
// case 0 {
|
||||
// let _1 := add(m, not(0))
|
||||
// let ret_1 := 0
|
||||
// switch _1
|
||||
// case 0 { ret_1 := 2 }
|
||||
// default {
|
||||
// ret_1 := A(add(m, not(1)), A_294(_1))
|
||||
// }
|
||||
// ret := ret_1
|
||||
// }
|
||||
// default {
|
||||
// let _2 := not(0)
|
||||
// ret := A(add(m, _2), A(m, add(n, _2)))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// function A_20869(n) -> ret
|
||||
// {
|
||||
// switch ret
|
||||
// case 0 { ret := add(n, 1) }
|
||||
// default {
|
||||
// switch n
|
||||
// case 0 {
|
||||
// let _1 := add(0, not(0))
|
||||
// let ret_1 := 0
|
||||
// switch _1
|
||||
// case 0 { ret_1 := 2 }
|
||||
// default {
|
||||
// ret_1 := A(add(0, not(1)), A_294(_1))
|
||||
// }
|
||||
// ret := ret_1
|
||||
// }
|
||||
// default {
|
||||
// let _2 := not(0)
|
||||
// ret := A(add(0, _2), A(0, add(n, _2)))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// function A_20875(n) -> ret
|
||||
// {
|
||||
// switch ret
|
||||
// case 0 { ret := add(n, 1) }
|
||||
// default {
|
||||
// switch n
|
||||
// case 0 {
|
||||
// let _1 := add(0, not(0))
|
||||
// let ret_1 := 0
|
||||
// switch _1
|
||||
// case 0 { ret_1 := 2 }
|
||||
// default {
|
||||
// ret_1 := A(add(0, not(1)), A_294(_1))
|
||||
// }
|
||||
// ret := ret_1
|
||||
// }
|
||||
// default {
|
||||
// let _2 := not(0)
|
||||
// ret := A(add(0, _2), A(0, add(n, _2)))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// function A_20876(n) -> ret
|
||||
// {
|
||||
// let m := 2
|
||||
// switch m
|
||||
// case 0 { ret := add(n, 1) }
|
||||
// default {
|
||||
// switch n
|
||||
// case 0 {
|
||||
// let _1 := add(m, not(0))
|
||||
// let ret_1 := 0
|
||||
// switch _1
|
||||
// case 0 { ret_1 := m }
|
||||
// default {
|
||||
// ret_1 := A(add(m, not(1)), A_294(_1))
|
||||
// }
|
||||
// ret := ret_1
|
||||
// }
|
||||
// default {
|
||||
// let _2 := not(0)
|
||||
// ret := A(add(m, _2), A(m, add(n, _2)))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// function A_20877(n) -> ret
|
||||
// {
|
||||
// let m := 1
|
||||
// switch m
|
||||
// case 0 { ret := add(n, m) }
|
||||
// default {
|
||||
// switch n
|
||||
// case 0 {
|
||||
// let _1 := add(m, not(0))
|
||||
// let ret_1 := 0
|
||||
// switch _1
|
||||
// case 0 { ret_1 := 2 }
|
||||
// default {
|
||||
// ret_1 := A(add(m, not(1)), A_294(_1))
|
||||
// }
|
||||
// ret := ret_1
|
||||
// }
|
||||
// default {
|
||||
// let _2 := not(0)
|
||||
// ret := A(add(m, _2), A(m, add(n, _2)))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// function A(m, n) -> ret
|
||||
// {
|
||||
// switch m
|
||||
// case 0 { ret := add(n, 1) }
|
||||
// default {
|
||||
// switch n
|
||||
// case 0 {
|
||||
// let _1 := add(m, not(0))
|
||||
// let ret_1 := 0
|
||||
// switch _1
|
||||
// case 0 { ret_1 := 2 }
|
||||
// default {
|
||||
// ret_1 := A(add(m, not(1)), A_294(_1))
|
||||
// }
|
||||
// ret := ret_1
|
||||
// }
|
||||
// default {
|
||||
// let _2 := not(0)
|
||||
// ret := A(add(m, _2), A(m, add(n, _2)))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
2492
test/libyul/yulOptimizerTests/fullSuite/ackermann_function_if.yul
Normal file
2492
test/libyul/yulOptimizerTests/fullSuite/ackermann_function_if.yul
Normal file
File diff suppressed because it is too large
Load Diff
@ -284,17 +284,15 @@
|
||||
// let _5 := 0x40
|
||||
// calldatacopy(0xe0, add(_3, 164), _5)
|
||||
// calldatacopy(0x20, add(_3, 100), _5)
|
||||
// let _6 := 0x120
|
||||
// mstore(_6, sub(_2, c))
|
||||
// let _7 := 0x60
|
||||
// mstore(_7, k)
|
||||
// mstore(0x120, sub(_2, c))
|
||||
// mstore(0x60, k)
|
||||
// mstore(0xc0, a)
|
||||
// let result := call(gas(), 7, 0, 0xe0, _7, 0x1a0, _5)
|
||||
// let result_1 := and(result, call(gas(), 7, 0, 0x20, _7, _6, _5))
|
||||
// let _8 := 0x160
|
||||
// let result_2 := and(result_1, call(gas(), 7, 0, 0x80, _7, _8, _5))
|
||||
// let result_3 := and(result_2, call(gas(), 6, 0, _6, 0x80, _8, _5))
|
||||
// result := and(result_3, call(gas(), 6, 0, _8, 0x80, b, _5))
|
||||
// let result := call(gas(), 7, 0, 0xe0, 0x60, 0x1a0, _5)
|
||||
// let result_1 := and(result, call(gas(), 7, 0, 0x20, 0x60, 0x120, _5))
|
||||
// let _6 := 0x160
|
||||
// let result_2 := and(result_1, call(gas(), 7, 0, 0x80, 0x60, _6, _5))
|
||||
// let result_3 := and(result_2, call(gas(), 6, 0, 0x120, 0x80, _6, _5))
|
||||
// result := and(result_3, call(gas(), 6, 0, _6, 0x80, b, _5))
|
||||
// if eq(i, m)
|
||||
// {
|
||||
// mstore(0x260, mload(0x20))
|
||||
@ -304,8 +302,8 @@
|
||||
// }
|
||||
// if gt(i, m)
|
||||
// {
|
||||
// mstore(_7, c)
|
||||
// let result_4 := and(result, call(gas(), 7, 0, 0x20, _7, 0x220, _5))
|
||||
// mstore(0x60, c)
|
||||
// let result_4 := and(result, call(gas(), 7, 0, 0x20, 0x60, 0x220, _5))
|
||||
// let result_5 := and(result_4, call(gas(), 6, 0, 0x220, 0x80, 0x260, _5))
|
||||
// result := and(result_5, call(gas(), 6, 0, 0x1a0, 0x80, 0x1e0, _5))
|
||||
// }
|
||||
@ -316,7 +314,7 @@
|
||||
// }
|
||||
// b := add(b, _5)
|
||||
// }
|
||||
// if lt(m, n) { validatePairing(100) }
|
||||
// if lt(m, n) { validatePairing() }
|
||||
// if iszero(eq(mod(keccak256(0x2a0, add(b, not(671))), _2), challenge))
|
||||
// {
|
||||
// mstore(0, 404)
|
||||
@ -325,40 +323,41 @@
|
||||
// mstore(0, 0x01)
|
||||
// return(0, 0x20)
|
||||
// }
|
||||
// function validatePairing(t2)
|
||||
// function validatePairing()
|
||||
// {
|
||||
// let t2_x := calldataload(t2)
|
||||
// let _1 := 0x20
|
||||
// let t2_x_1 := calldataload(add(t2, _1))
|
||||
// let t2_y := calldataload(add(t2, 0x40))
|
||||
// let t2_y_1 := calldataload(add(t2, 0x60))
|
||||
// let _2 := 0x90689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b
|
||||
// let _3 := 0x12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa
|
||||
// let _4 := 0x198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2
|
||||
// let _5 := 0x1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed
|
||||
// if or(or(or(or(or(or(or(iszero(t2_x), iszero(t2_x_1)), iszero(t2_y)), iszero(t2_y_1)), eq(t2_x, _5)), eq(t2_x_1, _4)), eq(t2_y, _3)), eq(t2_y_1, _2))
|
||||
// let t2_x := calldataload(0x64)
|
||||
// let t2_x_1 := calldataload(132)
|
||||
// let t2_y := calldataload(164)
|
||||
// let t2_y_1 := calldataload(196)
|
||||
// let _1 := 0x90689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b
|
||||
// let _2 := 0x12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa
|
||||
// let _3 := 0x198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2
|
||||
// let _4 := 0x1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed
|
||||
// if or(or(or(or(or(or(or(iszero(t2_x), iszero(t2_x_1)), iszero(t2_y)), iszero(t2_y_1)), eq(t2_x, _4)), eq(t2_x_1, _3)), eq(t2_y, _2)), eq(t2_y_1, _1))
|
||||
// {
|
||||
// mstore(0x00, 400)
|
||||
// revert(0x00, _1)
|
||||
// revert(0x00, 0x20)
|
||||
// }
|
||||
// mstore(_1, mload(0x1e0))
|
||||
// let _5 := mload(0x1e0)
|
||||
// let _6 := 0x20
|
||||
// mstore(_6, _5)
|
||||
// mstore(0x40, mload(0x200))
|
||||
// mstore(0x80, _5)
|
||||
// mstore(0x60, _4)
|
||||
// mstore(0xc0, _3)
|
||||
// mstore(0xa0, _2)
|
||||
// mstore(0x80, _4)
|
||||
// mstore(0x60, _3)
|
||||
// mstore(0xc0, _2)
|
||||
// mstore(0xa0, _1)
|
||||
// mstore(0xe0, mload(0x260))
|
||||
// mstore(0x100, mload(0x280))
|
||||
// mstore(0x140, t2_x)
|
||||
// mstore(0x120, t2_x_1)
|
||||
// let _6 := 0x180
|
||||
// mstore(_6, t2_y)
|
||||
// let _7 := 0x180
|
||||
// mstore(_7, t2_y)
|
||||
// mstore(0x160, t2_y_1)
|
||||
// let success := call(gas(), 8, 0, _1, _6, _1, _1)
|
||||
// if or(iszero(success), iszero(mload(_1)))
|
||||
// let success := call(gas(), 8, 0, _6, _7, _6, _6)
|
||||
// if or(iszero(success), iszero(mload(_6)))
|
||||
// {
|
||||
// mstore(0, 400)
|
||||
// revert(0, _1)
|
||||
// revert(0, _6)
|
||||
// }
|
||||
// }
|
||||
// function validateCommitment(note, k, a)
|
||||
|
39
test/libyul/yulOptimizerTests/fullSuite/fibonacci.yul
Normal file
39
test/libyul/yulOptimizerTests/fullSuite/fibonacci.yul
Normal file
@ -0,0 +1,39 @@
|
||||
{
|
||||
sstore(0, fib(0))
|
||||
sstore(1, fib(2))
|
||||
sstore(2, fib(3))
|
||||
sstore(3, fib(4))
|
||||
sstore(4, fib(5))
|
||||
sstore(5, fib(6))
|
||||
sstore(7, fib(7))
|
||||
sstore(8, fib(8))
|
||||
sstore(9, fib(9))
|
||||
sstore(10, fib(10))
|
||||
|
||||
|
||||
function fib(i) -> y
|
||||
{
|
||||
y := 1
|
||||
if gt(i, 2)
|
||||
{
|
||||
y := add(fib(sub(i, 1)), fib(sub(i, 2)))
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// step: fullSuite
|
||||
//
|
||||
// {
|
||||
// {
|
||||
// sstore(0, 1)
|
||||
// sstore(1, 1)
|
||||
// sstore(2, 2)
|
||||
// sstore(3, 3)
|
||||
// sstore(4, 5)
|
||||
// sstore(5, 8)
|
||||
// sstore(7, 13)
|
||||
// sstore(8, 21)
|
||||
// sstore(9, 34)
|
||||
// sstore(10, 55)
|
||||
// }
|
||||
// }
|
@ -17,14 +17,51 @@
|
||||
//
|
||||
// {
|
||||
// {
|
||||
// pop(mstore_(7))
|
||||
// pop(mstore_1011())
|
||||
// let y := 8
|
||||
// let _1 := calldataload(y)
|
||||
// sstore(y, _1)
|
||||
// sstore(y, _1)
|
||||
// sstore(y, _1)
|
||||
// sstore(y, _1)
|
||||
// sstore(y, _1)
|
||||
// sstore(y, _1)
|
||||
// sstore(y, _1)
|
||||
// sstore(y, _1)
|
||||
// sstore(y, _1)
|
||||
// sstore(y, _1)
|
||||
// sstore(y, _1)
|
||||
// nonmstore_1012()
|
||||
// let _2 := calldataload(2)
|
||||
// let _3 := 10
|
||||
// sstore(_3, _2)
|
||||
// sstore(_3, _2)
|
||||
// sstore(_3, _2)
|
||||
// sstore(_3, _2)
|
||||
// sstore(_3, _2)
|
||||
// sstore(_3, _2)
|
||||
// sstore(_3, _2)
|
||||
// sstore(_3, _2)
|
||||
// sstore(_3, _2)
|
||||
// sstore(_3, _2)
|
||||
// sstore(_3, _2)
|
||||
// }
|
||||
// function nonmstore_1012()
|
||||
// {
|
||||
// nonmstore(70)
|
||||
// sstore(10, calldataload(2))
|
||||
// }
|
||||
// function nonmstore(x)
|
||||
// {
|
||||
// nonmstore(x)
|
||||
// sstore(10, calldataload(2))
|
||||
// }
|
||||
// function mstore_1011() -> y
|
||||
// {
|
||||
// pop(mstore_(7))
|
||||
// y := 8
|
||||
// sstore(y, calldataload(y))
|
||||
// }
|
||||
// function mstore_(x) -> y
|
||||
// {
|
||||
// pop(mstore_(x))
|
||||
|
@ -16,14 +16,160 @@
|
||||
//
|
||||
// {
|
||||
// {
|
||||
// let dataoffset_ := datasize_(7)
|
||||
// sstore(dataoffset_, g(9))
|
||||
// let linkersymbol_1 := 0
|
||||
// let _1 := calldataload(linkersymbol_1)
|
||||
// if _1
|
||||
// {
|
||||
// let linkersymbol_2 := linkersymbol_1
|
||||
// if _1
|
||||
// {
|
||||
// let linkersymbol_3 := linkersymbol_1
|
||||
// if _1
|
||||
// {
|
||||
// let linkersymbol_4 := linkersymbol_1
|
||||
// if _1
|
||||
// {
|
||||
// let linkersymbol_5 := linkersymbol_1
|
||||
// if _1
|
||||
// {
|
||||
// linkersymbol_5 := datasize_1042()
|
||||
// }
|
||||
// sstore(linkersymbol_5, calldataload(linkersymbol_5))
|
||||
// linkersymbol_4 := linkersymbol_5
|
||||
// }
|
||||
// sstore(linkersymbol_4, calldataload(linkersymbol_4))
|
||||
// linkersymbol_3 := linkersymbol_4
|
||||
// }
|
||||
// sstore(linkersymbol_3, calldataload(linkersymbol_3))
|
||||
// linkersymbol_2 := linkersymbol_3
|
||||
// }
|
||||
// sstore(linkersymbol_2, calldataload(linkersymbol_2))
|
||||
// linkersymbol_1 := linkersymbol_2
|
||||
// }
|
||||
// sstore(linkersymbol_1, calldataload(linkersymbol_1))
|
||||
// let z := 0
|
||||
// let _2 := calldataload(1)
|
||||
// if _2
|
||||
// {
|
||||
// let z_1 := z
|
||||
// if _2
|
||||
// {
|
||||
// let z_2 := z
|
||||
// if _2
|
||||
// {
|
||||
// let z_3 := z
|
||||
// if _2 { z_3 := g_780() }
|
||||
// sstore(z_3, calldataload(10))
|
||||
// z_2 := z_3
|
||||
// }
|
||||
// sstore(z_2, calldataload(10))
|
||||
// z_1 := z_2
|
||||
// }
|
||||
// sstore(z_1, calldataload(10))
|
||||
// z := z_1
|
||||
// }
|
||||
// sstore(z, calldataload(10))
|
||||
// sstore(linkersymbol_1, z)
|
||||
// }
|
||||
// function g_780() -> z
|
||||
// {
|
||||
// let _1 := calldataload(1)
|
||||
// if _1
|
||||
// {
|
||||
// let z_1 := z
|
||||
// if _1
|
||||
// {
|
||||
// let z_2 := z
|
||||
// if _1
|
||||
// {
|
||||
// let z_3 := z
|
||||
// if _1
|
||||
// {
|
||||
// let z_4 := z
|
||||
// if _1
|
||||
// {
|
||||
// let z_5 := z
|
||||
// if _1
|
||||
// {
|
||||
// let z_6 := z
|
||||
// if _1 { z_6 := g_3303() }
|
||||
// sstore(z_6, calldataload(10))
|
||||
// z_5 := z_6
|
||||
// }
|
||||
// sstore(z_5, calldataload(10))
|
||||
// z_4 := z_5
|
||||
// }
|
||||
// sstore(z_4, calldataload(10))
|
||||
// z_3 := z_4
|
||||
// }
|
||||
// sstore(z_3, calldataload(10))
|
||||
// z_2 := z_3
|
||||
// }
|
||||
// sstore(z_2, calldataload(10))
|
||||
// z_1 := z_2
|
||||
// }
|
||||
// sstore(z_1, calldataload(10))
|
||||
// z := z_1
|
||||
// }
|
||||
// sstore(z, calldataload(10))
|
||||
// }
|
||||
// function g_3303() -> z
|
||||
// {
|
||||
// if calldataload(1) { z := g(9) }
|
||||
// sstore(z, calldataload(add(9, 1)))
|
||||
// }
|
||||
// function g(x) -> z
|
||||
// {
|
||||
// if calldataload(1) { z := g(x) }
|
||||
// sstore(z, calldataload(add(x, 1)))
|
||||
// }
|
||||
// function datasize_1042() -> linkersymbol_1
|
||||
// {
|
||||
// let _1 := calldataload(linkersymbol_1)
|
||||
// if _1
|
||||
// {
|
||||
// let linkersymbol_2 := linkersymbol_1
|
||||
// if _1
|
||||
// {
|
||||
// let linkersymbol_3 := linkersymbol_1
|
||||
// if _1
|
||||
// {
|
||||
// let linkersymbol_4 := linkersymbol_1
|
||||
// if _1
|
||||
// {
|
||||
// let linkersymbol_5 := linkersymbol_1
|
||||
// if _1
|
||||
// {
|
||||
// let linkersymbol_6 := linkersymbol_1
|
||||
// if _1
|
||||
// {
|
||||
// linkersymbol_6 := datasize_3305()
|
||||
// }
|
||||
// sstore(linkersymbol_6, calldataload(linkersymbol_6))
|
||||
// linkersymbol_5 := linkersymbol_6
|
||||
// }
|
||||
// sstore(linkersymbol_5, calldataload(linkersymbol_5))
|
||||
// linkersymbol_4 := linkersymbol_5
|
||||
// }
|
||||
// sstore(linkersymbol_4, calldataload(linkersymbol_4))
|
||||
// linkersymbol_3 := linkersymbol_4
|
||||
// }
|
||||
// sstore(linkersymbol_3, calldataload(linkersymbol_3))
|
||||
// linkersymbol_2 := linkersymbol_3
|
||||
// }
|
||||
// sstore(linkersymbol_2, calldataload(linkersymbol_2))
|
||||
// linkersymbol_1 := linkersymbol_2
|
||||
// }
|
||||
// sstore(linkersymbol_1, calldataload(linkersymbol_1))
|
||||
// }
|
||||
// function datasize_3305() -> linkersymbol_1
|
||||
// {
|
||||
// if calldataload(linkersymbol_1)
|
||||
// {
|
||||
// linkersymbol_1 := datasize_(7)
|
||||
// }
|
||||
// sstore(linkersymbol_1, calldataload(linkersymbol_1))
|
||||
// }
|
||||
// function datasize_(x) -> linkersymbol_
|
||||
// {
|
||||
// if calldataload(linkersymbol_) { linkersymbol_ := datasize_(x) }
|
||||
|
@ -38,21 +38,69 @@
|
||||
//
|
||||
// {
|
||||
// {
|
||||
// let _1 := gt(not(gcd(10, 15)), 1)
|
||||
// let _2 := gcd(10, 15)
|
||||
// let _1 := gt(not(gcd_1042()), 1)
|
||||
// let _2 := gcd_1043()
|
||||
// let _3 := not(0)
|
||||
// let _4 := lt(or(1, add(gcd(10, 15), _3)), 1)
|
||||
// let _5 := gcd(10, 15)
|
||||
// let _6 := gcd(10, 15)
|
||||
// pop(keccak256(gcd(10, 15), or(gt(not(gcd(10, 15)), 1), 1)))
|
||||
// let _4 := lt(or(1, add(gcd_1044(), _3)), 1)
|
||||
// let _5 := gcd_1045()
|
||||
// let _6 := gcd_1046()
|
||||
// pop(keccak256(gcd_1048(), or(gt(not(gcd_1047()), 1), 1)))
|
||||
// mstore(lt(or(gt(1, or(or(gt(or(or(or(gt(or(gt(_3, _6), 1), _5), _4), _2), 1), 1), _1), 1)), 1), 1), 1)
|
||||
// sstore(not(gcd(10, 15)), 1)
|
||||
// sstore(not(gcd_1049()), 1)
|
||||
// sstore(0, 0)
|
||||
// sstore(2, 1)
|
||||
// extcodecopy(1, msize(), 1, 1)
|
||||
// sstore(0, 0)
|
||||
// sstore(3, 1)
|
||||
// }
|
||||
// function gcd_1042() -> out
|
||||
// {
|
||||
// switch 5
|
||||
// case 0 { out := 10 }
|
||||
// default { out := gcd(5, mod(10, 5)) }
|
||||
// }
|
||||
// function gcd_1043() -> out
|
||||
// {
|
||||
// switch 5
|
||||
// case 0 { out := 10 }
|
||||
// default { out := gcd(5, mod(10, 5)) }
|
||||
// }
|
||||
// function gcd_1044() -> out
|
||||
// {
|
||||
// switch 5
|
||||
// case 0 { out := 10 }
|
||||
// default { out := gcd(5, mod(10, 5)) }
|
||||
// }
|
||||
// function gcd_1045() -> out
|
||||
// {
|
||||
// switch 5
|
||||
// case 0 { out := 10 }
|
||||
// default { out := gcd(5, mod(10, 5)) }
|
||||
// }
|
||||
// function gcd_1046() -> out
|
||||
// {
|
||||
// switch 5
|
||||
// case 0 { out := 10 }
|
||||
// default { out := gcd(5, mod(10, 5)) }
|
||||
// }
|
||||
// function gcd_1047() -> out
|
||||
// {
|
||||
// switch 5
|
||||
// case 0 { out := 10 }
|
||||
// default { out := gcd(5, mod(10, 5)) }
|
||||
// }
|
||||
// function gcd_1048() -> out
|
||||
// {
|
||||
// switch 5
|
||||
// case 0 { out := 10 }
|
||||
// default { out := gcd(5, mod(10, 5)) }
|
||||
// }
|
||||
// function gcd_1049() -> out
|
||||
// {
|
||||
// switch 5
|
||||
// case 0 { out := 10 }
|
||||
// default { out := gcd(5, mod(10, 5)) }
|
||||
// }
|
||||
// function gcd(_a, _b) -> out
|
||||
// {
|
||||
// switch _b
|
||||
|
@ -0,0 +1,35 @@
|
||||
{
|
||||
f(1, 2)
|
||||
|
||||
let x := 1
|
||||
f(x, 2)
|
||||
|
||||
f(calldataload(0), calldataload(1))
|
||||
|
||||
function f(a, b) {
|
||||
sstore(a, b)
|
||||
}
|
||||
|
||||
}
|
||||
// ----
|
||||
// step: functionSpecializer
|
||||
//
|
||||
// {
|
||||
// f_1()
|
||||
// let x := 1
|
||||
// f_2(x)
|
||||
// f(calldataload(0), calldataload(1))
|
||||
// function f_1()
|
||||
// {
|
||||
// let a_4 := 1
|
||||
// let b_3 := 2
|
||||
// sstore(a_4, b_3)
|
||||
// }
|
||||
// function f_2(a_6)
|
||||
// {
|
||||
// let b_5 := 2
|
||||
// sstore(a_6, b_5)
|
||||
// }
|
||||
// function f(a, b)
|
||||
// { sstore(a, b) }
|
||||
// }
|
@ -0,0 +1,33 @@
|
||||
{
|
||||
// All arguments are constants
|
||||
let x := 2
|
||||
f(1, x, 3)
|
||||
|
||||
function f(a, b, c) {
|
||||
sstore(a, b)
|
||||
sstore(b, c)
|
||||
// Prevents getting inlined
|
||||
if calldataload(0) { leave }
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// step: functionSpecializer
|
||||
//
|
||||
// {
|
||||
// let x := 2
|
||||
// f_1(x)
|
||||
// function f_1(b_3)
|
||||
// {
|
||||
// let a_4 := 1
|
||||
// let c_2 := 3
|
||||
// sstore(a_4, b_3)
|
||||
// sstore(b_3, c_2)
|
||||
// if calldataload(0) { leave }
|
||||
// }
|
||||
// function f(a, b, c)
|
||||
// {
|
||||
// sstore(a, b)
|
||||
// sstore(b, c)
|
||||
// if calldataload(0) { leave }
|
||||
// }
|
||||
// }
|
@ -0,0 +1,34 @@
|
||||
{
|
||||
sstore(0, fib(8))
|
||||
function fib(i) -> y
|
||||
{
|
||||
y := 1
|
||||
if gt(i, 2)
|
||||
{
|
||||
y := add(fib(sub(i, 1)), fib(sub(i, 2)))
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// step: functionSpecializer
|
||||
//
|
||||
// {
|
||||
// sstore(0, fib_1())
|
||||
// function fib_1() -> y_2
|
||||
// {
|
||||
// let i_3 := 8
|
||||
// y_2 := 1
|
||||
// if gt(i_3, 2)
|
||||
// {
|
||||
// y_2 := add(fib(sub(i_3, 1)), fib(sub(i_3, 2)))
|
||||
// }
|
||||
// }
|
||||
// function fib(i) -> y
|
||||
// {
|
||||
// y := 1
|
||||
// if gt(i, 2)
|
||||
// {
|
||||
// y := add(fib(sub(i, 1)), fib(sub(i, 2)))
|
||||
// }
|
||||
// }
|
||||
// }
|
28
test/libyul/yulOptimizerTests/functionSpecializer/simple.yul
Normal file
28
test/libyul/yulOptimizerTests/functionSpecializer/simple.yul
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
// All arguments are constants
|
||||
f(1, 2, 3)
|
||||
|
||||
function f(a, b, c) {
|
||||
sstore(a, b)
|
||||
sstore(b, c)
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// step: functionSpecializer
|
||||
//
|
||||
// {
|
||||
// f_1()
|
||||
// function f_1()
|
||||
// {
|
||||
// let a_4 := 1
|
||||
// let b_3 := 2
|
||||
// let c_2 := 3
|
||||
// sstore(a_4, b_3)
|
||||
// sstore(b_3, c_2)
|
||||
// }
|
||||
// function f(a, b, c)
|
||||
// {
|
||||
// sstore(a, b)
|
||||
// sstore(b, c)
|
||||
// }
|
||||
// }
|
@ -0,0 +1,5 @@
|
||||
{ }
|
||||
// ----
|
||||
// step: functionSpecializer
|
||||
//
|
||||
// { }
|
@ -138,7 +138,7 @@ BOOST_AUTO_TEST_CASE(output_operator_should_create_concise_and_unambiguous_strin
|
||||
|
||||
BOOST_TEST(chromosome.length() == allSteps.size());
|
||||
BOOST_TEST(chromosome.optimisationSteps() == allSteps);
|
||||
BOOST_TEST(toString(chromosome) == "flcCUnDvejsxIOoighTLMRrmVatpud");
|
||||
BOOST_TEST(toString(chromosome) == "flcCUnDvejsxIOoighFTLMRrmVatpud");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(optimisationSteps_should_translate_chromosomes_genes_to_optimisation_step_names)
|
||||
|
Loading…
Reference in New Issue
Block a user