aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-09-25 22:29:46 +0800
committerchriseth <chris@ethereum.org>2018-11-09 22:36:52 +0800
commit5ea514213a2ba15a8190f0171ddc003607faa679 (patch)
tree9deeb57578dbd46258992eb8cfe5e263ec95d460 /test
parentcbd0116e98862a36d6c904ed03d8d26b248838f0 (diff)
downloaddexon-solidity-5ea514213a2ba15a8190f0171ddc003607faa679.tar.gz
dexon-solidity-5ea514213a2ba15a8190f0171ddc003607faa679.tar.zst
dexon-solidity-5ea514213a2ba15a8190f0171ddc003607faa679.zip
Test case that shows that break/unbreak are more or less inverse.
Diffstat (limited to 'test')
-rw-r--r--test/libyul/YulOptimizerTest.cpp18
-rw-r--r--test/libyul/yulOptimizerTests/splitJoin/control_flow.yul26
-rw-r--r--test/libyul/yulOptimizerTests/splitJoin/functions.yul30
-rw-r--r--test/libyul/yulOptimizerTests/splitJoin/smoke.yul5
4 files changed, 74 insertions, 5 deletions
diff --git a/test/libyul/YulOptimizerTest.cpp b/test/libyul/YulOptimizerTest.cpp
index d455c892..03cd6446 100644
--- a/test/libyul/YulOptimizerTest.cpp
+++ b/test/libyul/YulOptimizerTest.cpp
@@ -118,6 +118,19 @@ bool YulOptimizerTest::run(ostream& _stream, string const& _linePrefix, bool con
NameDispenser nameDispenser(*m_ast);
ExpressionSplitter{nameDispenser}(*m_ast);
}
+ else if (m_optimizerStep == "expressionJoiner")
+ {
+ disambiguate();
+ ExpressionJoiner::run(*m_ast);
+ }
+ else if (m_optimizerStep == "splitJoin")
+ {
+ disambiguate();
+ NameDispenser nameDispenser(*m_ast);
+ ExpressionSplitter{nameDispenser}(*m_ast);
+ ExpressionJoiner::run(*m_ast);
+ ExpressionJoiner::run(*m_ast);
+ }
else if (m_optimizerStep == "functionGrouper")
{
disambiguate();
@@ -175,11 +188,6 @@ bool YulOptimizerTest::run(ostream& _stream, string const& _linePrefix, bool con
disambiguate();
UnusedPruner::runUntilStabilised(*m_ast);
}
- else if (m_optimizerStep == "expressionJoiner")
- {
- disambiguate();
- ExpressionJoiner::run(*m_ast);\
- }
else if (m_optimizerStep == "ssaTransform")
{
disambiguate();
diff --git a/test/libyul/yulOptimizerTests/splitJoin/control_flow.yul b/test/libyul/yulOptimizerTests/splitJoin/control_flow.yul
new file mode 100644
index 00000000..ad609c74
--- /dev/null
+++ b/test/libyul/yulOptimizerTests/splitJoin/control_flow.yul
@@ -0,0 +1,26 @@
+{
+ if mul(add(calldataload(0), 2), 3) {
+ for { let a := 2 } lt(a, mload(a)) { a := add(a, mul(a, 2)) } {
+ let b := mul(add(a, 2), 4)
+ sstore(b, mul(b, 2))
+ }
+ }
+}
+// ----
+// splitJoin
+// {
+// if mul(add(calldataload(0), 2), 3)
+// {
+// for {
+// let a := 2
+// }
+// lt(a, mload(a))
+// {
+// a := add(a, mul(a, 2))
+// }
+// {
+// let b := mul(add(a, 2), 4)
+// sstore(b, mul(b, 2))
+// }
+// }
+// }
diff --git a/test/libyul/yulOptimizerTests/splitJoin/functions.yul b/test/libyul/yulOptimizerTests/splitJoin/functions.yul
new file mode 100644
index 00000000..549fc550
--- /dev/null
+++ b/test/libyul/yulOptimizerTests/splitJoin/functions.yul
@@ -0,0 +1,30 @@
+{
+ let x := f(0)
+ function f(y) -> r {
+ r := mload(mul(6, add(y, 0x20)))
+ }
+ for { let a := 2 } lt(a, mload(a)) { a := add(a, mul(a, 2)) } {
+ let b := mul(add(a, f(a)), 4)
+ sstore(b, mul(b, 2))
+ }
+}
+// ----
+// splitJoin
+// {
+// let x := f(0)
+// function f(y) -> r
+// {
+// r := mload(mul(6, add(y, 0x20)))
+// }
+// for {
+// let a := 2
+// }
+// lt(a, mload(a))
+// {
+// a := add(a, mul(a, 2))
+// }
+// {
+// let b := mul(add(a, f(a)), 4)
+// sstore(b, mul(b, 2))
+// }
+// }
diff --git a/test/libyul/yulOptimizerTests/splitJoin/smoke.yul b/test/libyul/yulOptimizerTests/splitJoin/smoke.yul
new file mode 100644
index 00000000..4b133029
--- /dev/null
+++ b/test/libyul/yulOptimizerTests/splitJoin/smoke.yul
@@ -0,0 +1,5 @@
+{}
+// ----
+// splitJoin
+// {
+// }