From 9e9b643b935d5e02940b2161c67bd47e66de4918 Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 27 Nov 2019 11:51:06 +0100 Subject: [PATCH] Tune the suite. --- libyul/optimiser/Suite.cpp | 12 +++++++++++ ...remove_redundant_assignments_in_switch.yul | 20 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 test/libyul/yulOptimizerTests/fullSuite/remove_redundant_assignments_in_switch.yul diff --git a/libyul/optimiser/Suite.cpp b/libyul/optimiser/Suite.cpp index e35146e93..c7177e655 100644 --- a/libyul/optimiser/Suite.cpp +++ b/libyul/optimiser/Suite.cpp @@ -184,6 +184,18 @@ void OptimiserSuite::run( }, ast); } + { + // Prune a bit more in SSA + suite.runSequence({ + ExpressionSplitter::name, + SSATransform::name, + RedundantAssignEliminator::name, + UnusedPruner::name, + RedundantAssignEliminator::name, + UnusedPruner::name, + }, ast); + } + { // Turn into SSA again and simplify suite.runSequence({ diff --git a/test/libyul/yulOptimizerTests/fullSuite/remove_redundant_assignments_in_switch.yul b/test/libyul/yulOptimizerTests/fullSuite/remove_redundant_assignments_in_switch.yul new file mode 100644 index 000000000..fa1364297 --- /dev/null +++ b/test/libyul/yulOptimizerTests/fullSuite/remove_redundant_assignments_in_switch.yul @@ -0,0 +1,20 @@ + { + let x := 0 + switch mload(x) + case 0 { x := x } + case 1 { x := 1 } + default { invalid() } + mstore(1, 1) +} +// ==== +// step: fullSuite +// ---- +// { +// { +// switch mload(0) +// case 0 { } +// case 1 { } +// default { invalid() } +// mstore(1, 1) +// } +// }