aboutsummaryrefslogtreecommitdiffstats
path: root/test/libyul/yulOptimizerTests/expressionInliner
diff options
context:
space:
mode:
authorChristian Parpart <christian@ethereum.org>2018-10-15 17:52:35 +0800
committerChristian Parpart <christian@ethereum.org>2018-10-15 17:52:35 +0800
commit9a4bec7e474a310c7f93ff3b84928e0e9ba9cce6 (patch)
tree2668ab22a40aad2448081f7bf22c7235d4b4c963 /test/libyul/yulOptimizerTests/expressionInliner
parentb965fd6e17f77e94afeb070a27182251b85b8ab3 (diff)
downloaddexon-solidity-9a4bec7e474a310c7f93ff3b84928e0e9ba9cce6.tar.gz
dexon-solidity-9a4bec7e474a310c7f93ff3b84928e0e9ba9cce6.tar.zst
dexon-solidity-9a4bec7e474a310c7f93ff3b84928e0e9ba9cce6.zip
Renaming libjulia to libyul
Diffstat (limited to 'test/libyul/yulOptimizerTests/expressionInliner')
-rw-r--r--test/libyul/yulOptimizerTests/expressionInliner/complex_with_evm.yul13
-rw-r--r--test/libyul/yulOptimizerTests/expressionInliner/double_calls.yul18
-rw-r--r--test/libyul/yulOptimizerTests/expressionInliner/double_recursive_calls.yul18
-rw-r--r--test/libyul/yulOptimizerTests/expressionInliner/no_inline_mload.yul14
-rw-r--r--test/libyul/yulOptimizerTests/expressionInliner/no_move_with_sideeffects.yul27
-rw-r--r--test/libyul/yulOptimizerTests/expressionInliner/simple.yul14
-rw-r--r--test/libyul/yulOptimizerTests/expressionInliner/with_args.yul14
7 files changed, 118 insertions, 0 deletions
diff --git a/test/libyul/yulOptimizerTests/expressionInliner/complex_with_evm.yul b/test/libyul/yulOptimizerTests/expressionInliner/complex_with_evm.yul
new file mode 100644
index 00000000..519a2af8
--- /dev/null
+++ b/test/libyul/yulOptimizerTests/expressionInliner/complex_with_evm.yul
@@ -0,0 +1,13 @@
+{
+ function f(a) -> x { x := add(a, a) }
+ let y := f(calldatasize())
+}
+// ----
+// expressionInliner
+// {
+// function f(a) -> x
+// {
+// x := add(a, a)
+// }
+// let y := add(calldatasize(), calldatasize())
+// }
diff --git a/test/libyul/yulOptimizerTests/expressionInliner/double_calls.yul b/test/libyul/yulOptimizerTests/expressionInliner/double_calls.yul
new file mode 100644
index 00000000..e1da8e07
--- /dev/null
+++ b/test/libyul/yulOptimizerTests/expressionInliner/double_calls.yul
@@ -0,0 +1,18 @@
+{
+ function f(a) -> x { x := add(a, a) }
+ function g(b, c) -> y { y := mul(mload(c), f(b)) }
+ let y := g(calldatasize(), 7)
+}
+// ----
+// expressionInliner
+// {
+// function f(a) -> x
+// {
+// x := add(a, a)
+// }
+// function g(b, c) -> y
+// {
+// y := mul(mload(c), add(b, b))
+// }
+// let y_1 := mul(mload(7), add(calldatasize(), calldatasize()))
+// }
diff --git a/test/libyul/yulOptimizerTests/expressionInliner/double_recursive_calls.yul b/test/libyul/yulOptimizerTests/expressionInliner/double_recursive_calls.yul
new file mode 100644
index 00000000..082cb53f
--- /dev/null
+++ b/test/libyul/yulOptimizerTests/expressionInliner/double_recursive_calls.yul
@@ -0,0 +1,18 @@
+{
+ function f(a, r) -> x { x := g(a, g(r, r)) }
+ function g(b, s) -> y { y := f(b, f(s, s)) }
+ let y := g(calldatasize(), 7)
+}
+// ----
+// expressionInliner
+// {
+// function f(a, r) -> x
+// {
+// x := g(a, f(r, f(r, r)))
+// }
+// function g(b, s) -> y
+// {
+// y := f(b, g(s, f(s, f(s, s))))
+// }
+// let y_1 := f(calldatasize(), g(7, f(7, f(7, 7))))
+// }
diff --git a/test/libyul/yulOptimizerTests/expressionInliner/no_inline_mload.yul b/test/libyul/yulOptimizerTests/expressionInliner/no_inline_mload.yul
new file mode 100644
index 00000000..0fb43a9d
--- /dev/null
+++ b/test/libyul/yulOptimizerTests/expressionInliner/no_inline_mload.yul
@@ -0,0 +1,14 @@
+// Does not inline because mload could be moved out of sequence
+{
+ function f(a) -> x { x := a }
+ let y := f(mload(2))
+}
+// ----
+// expressionInliner
+// {
+// function f(a) -> x
+// {
+// x := a
+// }
+// let y := f(mload(2))
+// }
diff --git a/test/libyul/yulOptimizerTests/expressionInliner/no_move_with_sideeffects.yul b/test/libyul/yulOptimizerTests/expressionInliner/no_move_with_sideeffects.yul
new file mode 100644
index 00000000..7fdad6c4
--- /dev/null
+++ b/test/libyul/yulOptimizerTests/expressionInliner/no_move_with_sideeffects.yul
@@ -0,0 +1,27 @@
+// The calls to g and h cannot be moved because g and h are not movable. Therefore, the call
+// to f is not inlined.
+{
+ function f(a, b) -> x { x := add(b, a) }
+ function g() -> y { y := mload(0) mstore(0, 4) }
+ function h() -> z { mstore(0, 4) z := mload(0) }
+ let r := f(g(), h())
+}
+// ----
+// expressionInliner
+// {
+// function f(a, b) -> x
+// {
+// x := add(b, a)
+// }
+// function g() -> y
+// {
+// y := mload(0)
+// mstore(0, 4)
+// }
+// function h() -> z
+// {
+// mstore(0, 4)
+// z := mload(0)
+// }
+// let r := f(g(), h())
+// }
diff --git a/test/libyul/yulOptimizerTests/expressionInliner/simple.yul b/test/libyul/yulOptimizerTests/expressionInliner/simple.yul
new file mode 100644
index 00000000..c186eafd
--- /dev/null
+++ b/test/libyul/yulOptimizerTests/expressionInliner/simple.yul
@@ -0,0 +1,14 @@
+// yul
+{
+ function f() -> x:u256 { x := 2:u256 }
+ let y:u256 := f()
+}
+// ----
+// expressionInliner
+// {
+// function f() -> x:u256
+// {
+// x := 2:u256
+// }
+// let y:u256 := 2:u256
+// }
diff --git a/test/libyul/yulOptimizerTests/expressionInliner/with_args.yul b/test/libyul/yulOptimizerTests/expressionInliner/with_args.yul
new file mode 100644
index 00000000..b5f4d515
--- /dev/null
+++ b/test/libyul/yulOptimizerTests/expressionInliner/with_args.yul
@@ -0,0 +1,14 @@
+// yul
+{
+ function f(a:u256) -> x:u256 { x := a }
+ let y:u256 := f(7:u256)
+}
+// ----
+// expressionInliner
+// {
+// function f(a:u256) -> x:u256
+// {
+// x := a
+// }
+// let y:u256 := 7:u256
+// }