-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added more tests. Updated chromosome. Remove unused headers.
- Loading branch information
Showing
10 changed files
with
172 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
25 changes: 25 additions & 0 deletions
25
test/libyul/yulOptimizerTests/equalStoreEliminator/branching.yul
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
let a := calldataload(0) | ||
let b := 20 | ||
sstore(a, b) | ||
if calldataload(32) { | ||
sstore(a, b) | ||
pop(staticcall(0, 0, 0, 0, 0, 0)) | ||
sstore(a, b) | ||
} | ||
sstore(a, b) | ||
} | ||
// ==== | ||
// EVMVersion: >=byzantium | ||
// ---- | ||
// step: equalStoreEliminator | ||
// | ||
// { | ||
// let a := calldataload(0) | ||
// let b := 20 | ||
// sstore(a, b) | ||
// if calldataload(32) | ||
// { | ||
// pop(staticcall(0, 0, 0, 0, 0, 0)) | ||
// } | ||
// } |
20 changes: 20 additions & 0 deletions
20
test/libyul/yulOptimizerTests/equalStoreEliminator/forloop.yul
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
let x := calldataload(0) | ||
let y := calldataload(1) | ||
|
||
sstore(x, y) | ||
for {let a := 1} lt(a, 10) {a := add(a, 1) } { | ||
sstore(x, y) | ||
} | ||
} | ||
// ---- | ||
// step: equalStoreEliminator | ||
// | ||
// { | ||
// let x := calldataload(0) | ||
// let y := calldataload(1) | ||
// sstore(x, y) | ||
// let a := 1 | ||
// for { } lt(a, 10) { a := add(a, 1) } | ||
// { sstore(x, y) } | ||
// } |
56 changes: 56 additions & 0 deletions
56
test/libyul/yulOptimizerTests/equalStoreEliminator/functionbody.yul
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ | ||
f(calldataload(0), calldataload(32)) | ||
h(calldataload(64), calldataload(96)) | ||
|
||
function f(a, b) { | ||
// gets removed | ||
sstore(a, b) | ||
g() | ||
sstore(a, b) | ||
} | ||
|
||
function g() { | ||
pop(staticcall(0, 0, 0, 0, 0, 0)) | ||
} | ||
|
||
function h(a_, b_) { | ||
// cannot be removed | ||
sstore(a_, b_) | ||
i() | ||
sstore(a_, b_) | ||
} | ||
|
||
function i() { | ||
pop(delegatecall(0, 0, 0, 0, 0, 0)) | ||
} | ||
|
||
|
||
} | ||
// ==== | ||
// EVMVersion: >=byzantium | ||
// ---- | ||
// step: equalStoreEliminator | ||
// | ||
// { | ||
// f(calldataload(0), calldataload(32)) | ||
// h(calldataload(64), calldataload(96)) | ||
// function f(a, b) | ||
// { | ||
// sstore(a, b) | ||
// g() | ||
// } | ||
// function g() | ||
// { | ||
// pop(staticcall(0, 0, 0, 0, 0, 0)) | ||
// } | ||
// function h(a_, b_) | ||
// { | ||
// sstore(a_, b_) | ||
// i() | ||
// sstore(a_, b_) | ||
// } | ||
// function i() | ||
// { | ||
// pop(delegatecall(0, 0, 0, 0, 0, 0)) | ||
// } | ||
// } |
24 changes: 24 additions & 0 deletions
24
test/libyul/yulOptimizerTests/equalStoreEliminator/indirect_inferrence.yul
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
let x := calldataload(0) | ||
let y := sload(x) | ||
// both of these can be removed | ||
sstore(x, y) | ||
sstore(x, y) | ||
|
||
let a := x | ||
let b := mload(a) | ||
// both of these can be removed | ||
mstore(a, b) | ||
mstore(a, b) | ||
} | ||
// ==== | ||
// EVMVersion: >=byzantium | ||
// ---- | ||
// step: equalStoreEliminator | ||
// | ||
// { | ||
// let x := calldataload(0) | ||
// let y := sload(x) | ||
// let a := x | ||
// let b := mload(a) | ||
// } |
18 changes: 18 additions & 0 deletions
18
test/libyul/yulOptimizerTests/equalStoreEliminator/value_change.yul
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
let x := calldataload(0) | ||
let y := calldataload(32) | ||
sstore(x, y) | ||
y := calldataload(64) | ||
// cannot be removed | ||
sstore(x, y) | ||
} | ||
// ---- | ||
// step: equalStoreEliminator | ||
// | ||
// { | ||
// let x := calldataload(0) | ||
// let y := calldataload(32) | ||
// sstore(x, y) | ||
// y := calldataload(64) | ||
// sstore(x, y) | ||
// } |
27 changes: 27 additions & 0 deletions
27
test/libyul/yulOptimizerTests/equalStoreEliminator/verbatim.yul
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
let a := calldataload(0) | ||
let b := 20 | ||
sstore(a, b) | ||
if calldataload(32) { | ||
sstore(a, b) | ||
pop(staticcall(0, 0, 0, 0, 0, 0)) | ||
verbatim_0i_0o("xyz") | ||
} | ||
sstore(a, b) | ||
} | ||
// ==== | ||
// EVMVersion: >=byzantium | ||
// ---- | ||
// step: equalStoreEliminator | ||
// | ||
// { | ||
// let a := calldataload(0) | ||
// let b := 20 | ||
// sstore(a, b) | ||
// if calldataload(32) | ||
// { | ||
// pop(staticcall(0, 0, 0, 0, 0, 0)) | ||
// verbatim_0i_0o("xyz") | ||
// } | ||
// sstore(a, b) | ||
// } |
This file contains 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