diff options
author | Christian Parpart <christian@parpart.family> | 2018-11-07 18:18:02 +0800 |
---|---|---|
committer | Christian Parpart <christian@ethereum.org> | 2018-11-16 20:15:41 +0800 |
commit | f705a45d43d69ca4f29bd496d091f7237bdc31ff (patch) | |
tree | e176c4b1d512bc9f2b0e0353a125a535ccf69691 /test/libyul | |
parent | 460c58fbd194fef5add699405238d3ed302a003f (diff) | |
download | dexon-solidity-f705a45d43d69ca4f29bd496d091f7237bdc31ff.tar dexon-solidity-f705a45d43d69ca4f29bd496d091f7237bdc31ff.tar.gz dexon-solidity-f705a45d43d69ca4f29bd496d091f7237bdc31ff.tar.bz2 dexon-solidity-f705a45d43d69ca4f29bd496d091f7237bdc31ff.tar.lz dexon-solidity-f705a45d43d69ca4f29bd496d091f7237bdc31ff.tar.xz dexon-solidity-f705a45d43d69ca4f29bd496d091f7237bdc31ff.tar.zst dexon-solidity-f705a45d43d69ca4f29bd496d091f7237bdc31ff.zip |
[Yul] Implements a pass to rewrite for-loop's pre block into the parent's Block.
Diffstat (limited to 'test/libyul')
4 files changed, 70 insertions, 0 deletions
diff --git a/test/libyul/YulOptimizerTest.cpp b/test/libyul/YulOptimizerTest.cpp index 03cd6446..9e257717 100644 --- a/test/libyul/YulOptimizerTest.cpp +++ b/test/libyul/YulOptimizerTest.cpp @@ -31,6 +31,7 @@ #include <libyul/optimiser/FunctionHoister.h> #include <libyul/optimiser/ExpressionInliner.h> #include <libyul/optimiser/FullInliner.h> +#include <libyul/optimiser/ForLoopInitRewriter.h> #include <libyul/optimiser/MainFunction.h> #include <libyul/optimiser/Rematerialiser.h> #include <libyul/optimiser/ExpressionSimplifier.h> @@ -108,6 +109,11 @@ bool YulOptimizerTest::run(ostream& _stream, string const& _linePrefix, bool con disambiguate(); VarDeclPropagator{}(*m_ast); } + else if (m_optimizerStep == "forLoopInitRewriter") + { + disambiguate(); + ForLoopInitRewriter{}(*m_ast); + } else if (m_optimizerStep == "commonSubexpressionEliminator") { disambiguate(); diff --git a/test/libyul/yulOptimizerTests/forLoopInitRewriter/complex_pre.yul b/test/libyul/yulOptimizerTests/forLoopInitRewriter/complex_pre.yul new file mode 100644 index 00000000..3ca00f55 --- /dev/null +++ b/test/libyul/yulOptimizerTests/forLoopInitRewriter/complex_pre.yul @@ -0,0 +1,23 @@ +{ + let random := 42 + for { let a := 1 + let b := 1 } iszero(eq(a, 10)) { a := add(a, b) } { + a := add(a, 1) + } +} +// ---- +// forLoopInitRewriter +// { +// let random := 42 +// let a := 1 +// let b := 1 +// for { +// } +// iszero(eq(a, 10)) +// { +// a := add(a, b) +// } +// { +// a := add(a, 1) +// } +// } diff --git a/test/libyul/yulOptimizerTests/forLoopInitRewriter/empty_pre.yul b/test/libyul/yulOptimizerTests/forLoopInitRewriter/empty_pre.yul new file mode 100644 index 00000000..05aceb52 --- /dev/null +++ b/test/libyul/yulOptimizerTests/forLoopInitRewriter/empty_pre.yul @@ -0,0 +1,20 @@ +{ + let a := 1 + for {} iszero(eq(a, 10)) { a := add(a, 1) } { + a := add(a, 1) + } +} +// ---- +// forLoopInitRewriter +// { +// let a := 1 +// for { +// } +// iszero(eq(a, 10)) +// { +// a := add(a, 1) +// } +// { +// a := add(a, 1) +// } +// } diff --git a/test/libyul/yulOptimizerTests/forLoopInitRewriter/simple.yul b/test/libyul/yulOptimizerTests/forLoopInitRewriter/simple.yul new file mode 100644 index 00000000..565b7725 --- /dev/null +++ b/test/libyul/yulOptimizerTests/forLoopInitRewriter/simple.yul @@ -0,0 +1,21 @@ +{ + let random := 42 + for { let a := 1 } iszero(eq(a, 10)) { a := add(a, 1) } { + a := add(a, 1) + } +} +// ---- +// forLoopInitRewriter +// { +// let random := 42 +// let a := 1 +// for { +// } +// iszero(eq(a, 10)) +// { +// a := add(a, 1) +// } +// { +// a := add(a, 1) +// } +// } |