Last active
April 8, 2021 09:06
-
-
Save hrkrshnn/8b269934324cbbd8b9bd2652650e2060 to your computer and use it in GitHub Desktop.
extra memory copy example. Memory Store remover
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
let x := 64 | |
// can be removed | |
mstore(x, 128) | |
if iszero(lt(calldatasize(), 4)) | |
{ | |
let _1 := 0 | |
if eq(0x8868a931, shr(224, calldataload(_1))) | |
{ | |
if callvalue() { revert(_1, _1) } | |
if slt(add(calldatasize(), not(3)), 32) { revert(_1, _1) } | |
// can be removed | |
mstore(x, 160) | |
let _2 := calldataload(4) | |
let y := 128 | |
// can be removed. The extra copy | |
mstore(y, _2) | |
let z := 160 | |
mstore(z, _2) | |
log1(160, 32, 0x212c52355da9347c37e2f79c330f6a3f39d08b38b62c96451f574d1878a87676) | |
// can be removed | |
mstore(x, 160) | |
return(160, _1) | |
} | |
} | |
revert(0, 0) | |
} | |
// ---- | |
// step: memoryStoreRemover | |
// | |
// { | |
// let x := 64 | |
// pop(128) | |
// if iszero(lt(calldatasize(), 4)) | |
// { | |
// let _1 := 0 | |
// if eq(0x8868a931, shr(224, calldataload(_1))) | |
// { | |
// if callvalue() { revert(_1, _1) } | |
// if slt(add(calldatasize(), not(3)), 32) { revert(_1, _1) } | |
// pop(160) | |
// let _2 := calldataload(4) | |
// let y := 128 | |
// pop(_2) | |
// let z := 160 | |
// mstore(z, _2) | |
// log1(160, 32, 0x212c52355da9347c37e2f79c330f6a3f39d08b38b62c96451f574d1878a87676) | |
// pop(160) | |
// return(160, _1) | |
// } | |
// } | |
// revert(0, 0) | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment