aboutsummaryrefslogtreecommitdiffstats
path: root/test/libyul/yulOptimizerTests
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-12-12 07:49:36 +0800
committerchriseth <chris@ethereum.org>2018-12-13 01:06:28 +0800
commit9557dd7e74a801ebafaf4777d60a591b0c484779 (patch)
treeb55af218e8debaeb4a79670f932e1e66afb736b6 /test/libyul/yulOptimizerTests
parent5e0c312dad2daaae155486397bfbd26d6d172718 (diff)
downloaddexon-solidity-9557dd7e74a801ebafaf4777d60a591b0c484779.tar.gz
dexon-solidity-9557dd7e74a801ebafaf4777d60a591b0c484779.tar.zst
dexon-solidity-9557dd7e74a801ebafaf4777d60a591b0c484779.zip
Support unassigned variables in the SSA value tracker and the data flow analyzer.
Diffstat (limited to 'test/libyul/yulOptimizerTests')
-rw-r--r--test/libyul/yulOptimizerTests/commonSubexpressionEliminator/unassigned_variables.yul14
-rw-r--r--test/libyul/yulOptimizerTests/expressionSimplifier/unassigend_vars_multi.yul5
-rw-r--r--test/libyul/yulOptimizerTests/expressionSimplifier/unassigned_vars.yul5
-rw-r--r--test/libyul/yulOptimizerTests/fullInliner/large_function_multi_use.yul13
-rw-r--r--test/libyul/yulOptimizerTests/structuralSimplifier/if_multi_unassigned_condition.yul10
-rw-r--r--test/libyul/yulOptimizerTests/structuralSimplifier/if_unassigned_condition.yul9
6 files changed, 50 insertions, 6 deletions
diff --git a/test/libyul/yulOptimizerTests/commonSubexpressionEliminator/unassigned_variables.yul b/test/libyul/yulOptimizerTests/commonSubexpressionEliminator/unassigned_variables.yul
new file mode 100644
index 00000000..a790ca65
--- /dev/null
+++ b/test/libyul/yulOptimizerTests/commonSubexpressionEliminator/unassigned_variables.yul
@@ -0,0 +1,14 @@
+{
+ // This does not replace b by a because there is no
+ // explicit assignment, even though both hold the same value.
+ let a
+ let b
+ mstore(sub(a, b), 7)
+}
+// ----
+// commonSubexpressionEliminator
+// {
+// let a
+// let b
+// mstore(sub(a, b), 7)
+// }
diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/unassigend_vars_multi.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/unassigend_vars_multi.yul
index 8c1ad789..f260db0b 100644
--- a/test/libyul/yulOptimizerTests/expressionSimplifier/unassigend_vars_multi.yul
+++ b/test/libyul/yulOptimizerTests/expressionSimplifier/unassigend_vars_multi.yul
@@ -1,5 +1,4 @@
-// c & d can't be optimized as expression simplifier doesn't handle default
-// values yet
+// Unassigned variables are assumed to be zero.
{
let c, d
let y := add(d, add(c, 7))
@@ -8,5 +7,5 @@
// expressionSimplifier
// {
// let c, d
-// let y := add(add(d, c), 7)
+// let y := 7
// }
diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/unassigned_vars.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/unassigned_vars.yul
index 87391b8c..7b1430f3 100644
--- a/test/libyul/yulOptimizerTests/expressionSimplifier/unassigned_vars.yul
+++ b/test/libyul/yulOptimizerTests/expressionSimplifier/unassigned_vars.yul
@@ -1,5 +1,4 @@
-// c & d can't be optimized as expression simplifier doesn't handle default
-// values yet
+// Unassigned variables are assumed to be zero.
{
let c
let d
@@ -10,5 +9,5 @@
// {
// let c
// let d
-// let y := add(add(d, c), 7)
+// let y := 7
// }
diff --git a/test/libyul/yulOptimizerTests/fullInliner/large_function_multi_use.yul b/test/libyul/yulOptimizerTests/fullInliner/large_function_multi_use.yul
index 0972ac56..ec44dafb 100644
--- a/test/libyul/yulOptimizerTests/fullInliner/large_function_multi_use.yul
+++ b/test/libyul/yulOptimizerTests/fullInliner/large_function_multi_use.yul
@@ -13,6 +13,9 @@
let r := f(a)
// This should be inlined because it is a constant
let t := f(a2)
+ let a3
+ // This should be inlined because it is a constant as well (zero)
+ let s := f(a3)
}
// ----
// fullInliner
@@ -30,6 +33,16 @@
// let f_y := add(f_a, f_x)
// sstore(f_y, 10)
// let t := f_b
+// let a3
+// let f_a_5 := a3
+// let f_b_6
+// let f_x_7 := mload(f_a_5)
+// f_b_6 := sload(f_x_7)
+// let f_c_8 := 3
+// mstore(mul(f_a_5, f_b_6), mload(f_x_7))
+// let f_y_11 := add(f_a_5, f_x_7)
+// sstore(f_y_11, 10)
+// let s := f_b_6
// }
// function f(a) -> b
// {
diff --git a/test/libyul/yulOptimizerTests/structuralSimplifier/if_multi_unassigned_condition.yul b/test/libyul/yulOptimizerTests/structuralSimplifier/if_multi_unassigned_condition.yul
new file mode 100644
index 00000000..0ece5dbd
--- /dev/null
+++ b/test/libyul/yulOptimizerTests/structuralSimplifier/if_multi_unassigned_condition.yul
@@ -0,0 +1,10 @@
+{
+ let x, y
+ if x { mstore(0, 0) }
+ if y { mstore(0, 0) }
+}
+// ----
+// structuralSimplifier
+// {
+// let x, y
+// }
diff --git a/test/libyul/yulOptimizerTests/structuralSimplifier/if_unassigned_condition.yul b/test/libyul/yulOptimizerTests/structuralSimplifier/if_unassigned_condition.yul
new file mode 100644
index 00000000..a327a882
--- /dev/null
+++ b/test/libyul/yulOptimizerTests/structuralSimplifier/if_unassigned_condition.yul
@@ -0,0 +1,9 @@
+{
+ let x
+ if x { mstore(0, 0) }
+}
+// ----
+// structuralSimplifier
+// {
+// let x
+// }