aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/libyul/YulOptimizerTest.cpp6
-rw-r--r--test/libyul/yulOptimizerTests/varDeclPropagator/init_assignment_inside_if.yul17
-rw-r--r--test/libyul/yulOptimizerTests/varDeclPropagator/multi_assignment_vardecl.yul13
-rw-r--r--test/libyul/yulOptimizerTests/varDeclPropagator/overwrite.yul11
-rw-r--r--test/libyul/yulOptimizerTests/varDeclPropagator/rewrite_removes_unused_var.yul10
-rw-r--r--test/libyul/yulOptimizerTests/varDeclPropagator/simple1.yul9
-rw-r--r--test/libyul/yulOptimizerTests/varDeclPropagator/split_assign_splits_vardecl.yul11
-rw-r--r--test/libyul/yulOptimizerTests/varDeclPropagator/use_before_init.yul12
-rw-r--r--test/libyul/yulOptimizerTests/varDeclPropagator/use_doesnt_rewrite.yul16
9 files changed, 105 insertions, 0 deletions
diff --git a/test/libyul/YulOptimizerTest.cpp b/test/libyul/YulOptimizerTest.cpp
index 0378764d..d455c892 100644
--- a/test/libyul/YulOptimizerTest.cpp
+++ b/test/libyul/YulOptimizerTest.cpp
@@ -22,6 +22,7 @@
#include <test/Options.h>
#include <libyul/optimiser/BlockFlattener.h>
+#include <libyul/optimiser/VarDeclPropagator.h>
#include <libyul/optimiser/Disambiguator.h>
#include <libyul/optimiser/CommonSubexpressionEliminator.h>
#include <libyul/optimiser/NameCollector.h>
@@ -102,6 +103,11 @@ bool YulOptimizerTest::run(ostream& _stream, string const& _linePrefix, bool con
disambiguate();
BlockFlattener{}(*m_ast);
}
+ else if (m_optimizerStep == "varDeclPropagator")
+ {
+ disambiguate();
+ VarDeclPropagator{}(*m_ast);
+ }
else if (m_optimizerStep == "commonSubexpressionEliminator")
{
disambiguate();
diff --git a/test/libyul/yulOptimizerTests/varDeclPropagator/init_assignment_inside_if.yul b/test/libyul/yulOptimizerTests/varDeclPropagator/init_assignment_inside_if.yul
new file mode 100644
index 00000000..54fea2fb
--- /dev/null
+++ b/test/libyul/yulOptimizerTests/varDeclPropagator/init_assignment_inside_if.yul
@@ -0,0 +1,17 @@
+{
+ let a := 4
+ let x
+ if a {
+ x := 2
+ }
+}
+// ----
+// varDeclPropagator
+// {
+// let a := 4
+// let x
+// if a
+// {
+// x := 2
+// }
+// }
diff --git a/test/libyul/yulOptimizerTests/varDeclPropagator/multi_assignment_vardecl.yul b/test/libyul/yulOptimizerTests/varDeclPropagator/multi_assignment_vardecl.yul
new file mode 100644
index 00000000..4ac07031
--- /dev/null
+++ b/test/libyul/yulOptimizerTests/varDeclPropagator/multi_assignment_vardecl.yul
@@ -0,0 +1,13 @@
+{
+ function f() -> a, b, c {}
+ let x, y, z
+ z, x, y := f()
+}
+// ----
+// varDeclPropagator
+// {
+// function f() -> a, b, c
+// {
+// }
+// let z, x, y := f()
+// }
diff --git a/test/libyul/yulOptimizerTests/varDeclPropagator/overwrite.yul b/test/libyul/yulOptimizerTests/varDeclPropagator/overwrite.yul
new file mode 100644
index 00000000..ca921500
--- /dev/null
+++ b/test/libyul/yulOptimizerTests/varDeclPropagator/overwrite.yul
@@ -0,0 +1,11 @@
+{
+ let a
+ a := 4
+ a := 5
+}
+// ----
+// varDeclPropagator
+// {
+// let a := 4
+// a := 5
+// }
diff --git a/test/libyul/yulOptimizerTests/varDeclPropagator/rewrite_removes_unused_var.yul b/test/libyul/yulOptimizerTests/varDeclPropagator/rewrite_removes_unused_var.yul
new file mode 100644
index 00000000..3affcac6
--- /dev/null
+++ b/test/libyul/yulOptimizerTests/varDeclPropagator/rewrite_removes_unused_var.yul
@@ -0,0 +1,10 @@
+{
+ let a, b
+ a := mload(0)
+}
+// ----
+// varDeclPropagator
+// {
+// let b
+// let a := mload(0)
+// }
diff --git a/test/libyul/yulOptimizerTests/varDeclPropagator/simple1.yul b/test/libyul/yulOptimizerTests/varDeclPropagator/simple1.yul
new file mode 100644
index 00000000..117e0cc9
--- /dev/null
+++ b/test/libyul/yulOptimizerTests/varDeclPropagator/simple1.yul
@@ -0,0 +1,9 @@
+{
+ let f
+ f := mload(0)
+}
+// ----
+// varDeclPropagator
+// {
+// let f := mload(0)
+// }
diff --git a/test/libyul/yulOptimizerTests/varDeclPropagator/split_assign_splits_vardecl.yul b/test/libyul/yulOptimizerTests/varDeclPropagator/split_assign_splits_vardecl.yul
new file mode 100644
index 00000000..e8c91e10
--- /dev/null
+++ b/test/libyul/yulOptimizerTests/varDeclPropagator/split_assign_splits_vardecl.yul
@@ -0,0 +1,11 @@
+{
+ let a, b
+ a := mload(0)
+ b := mload(1)
+}
+// ----
+// varDeclPropagator
+// {
+// let a := mload(0)
+// let b := mload(1)
+// }
diff --git a/test/libyul/yulOptimizerTests/varDeclPropagator/use_before_init.yul b/test/libyul/yulOptimizerTests/varDeclPropagator/use_before_init.yul
new file mode 100644
index 00000000..5312112a
--- /dev/null
+++ b/test/libyul/yulOptimizerTests/varDeclPropagator/use_before_init.yul
@@ -0,0 +1,12 @@
+{
+ let b
+ let a := b
+ b := 1
+}
+// ----
+// varDeclPropagator
+// {
+// let b
+// let a := b
+// b := 1
+// }
diff --git a/test/libyul/yulOptimizerTests/varDeclPropagator/use_doesnt_rewrite.yul b/test/libyul/yulOptimizerTests/varDeclPropagator/use_doesnt_rewrite.yul
new file mode 100644
index 00000000..e27785dd
--- /dev/null
+++ b/test/libyul/yulOptimizerTests/varDeclPropagator/use_doesnt_rewrite.yul
@@ -0,0 +1,16 @@
+{
+ function f(x) {}
+ let a
+ f(a)
+ a := 4
+}
+// ----
+// varDeclPropagator
+// {
+// function f(x)
+// {
+// }
+// let a
+// f(a)
+// a := 4
+// }