diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/libyul/YulOptimizerTest.cpp | 6 | ||||
-rw-r--r-- | test/libyul/yulOptimizerTests/forLoopInitRewriter/complex_pre.yul | 23 | ||||
-rw-r--r-- | test/libyul/yulOptimizerTests/forLoopInitRewriter/empty_pre.yul | 20 | ||||
-rw-r--r-- | test/libyul/yulOptimizerTests/forLoopInitRewriter/simple.yul | 21 | ||||
-rw-r--r-- | test/tools/yulopti.cpp | 6 |
5 files changed, 75 insertions, 1 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) +// } +// } diff --git a/test/tools/yulopti.cpp b/test/tools/yulopti.cpp index 348c5f4a..3e96ef35 100644 --- a/test/tools/yulopti.cpp +++ b/test/tools/yulopti.cpp @@ -38,6 +38,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> @@ -123,7 +124,7 @@ public: } cout << "(q)quit/(f)flatten/(c)se/propagate var(d)ecls/(x)plit/(j)oin/(g)rouper/(h)oister/" << endl; cout << " (e)xpr inline/(i)nline/(s)implify/(u)nusedprune/ss(a) transform/" << endl; - cout << " (r)edundant assign elim./re(m)aterializer? "; + cout << " (r)edundant assign elim./re(m)aterializer/f(o)r-loop-pre-rewriter? "; cout.flush(); int option = readStandardInputChar(); cout << ' ' << char(option) << endl; @@ -134,6 +135,9 @@ public: case 'f': BlockFlattener{}(*m_ast); break; + case 'o': + ForLoopInitRewriter{}(*m_ast); + break; case 'c': (CommonSubexpressionEliminator{})(*m_ast); break; |