From 5ea514213a2ba15a8190f0171ddc003607faa679 Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 25 Sep 2018 16:29:46 +0200 Subject: Test case that shows that break/unbreak are more or less inverse. --- test/libyul/YulOptimizerTest.cpp | 18 +++++++++---- .../yulOptimizerTests/splitJoin/control_flow.yul | 26 +++++++++++++++++++ .../yulOptimizerTests/splitJoin/functions.yul | 30 ++++++++++++++++++++++ test/libyul/yulOptimizerTests/splitJoin/smoke.yul | 5 ++++ 4 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 test/libyul/yulOptimizerTests/splitJoin/control_flow.yul create mode 100644 test/libyul/yulOptimizerTests/splitJoin/functions.yul create mode 100644 test/libyul/yulOptimizerTests/splitJoin/smoke.yul (limited to 'test/libyul') 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 +// { +// } -- cgit