diff --git a/libsolidity/interface/OptimiserSettings.h b/libsolidity/interface/OptimiserSettings.h
index 3df99325e..990981bc9 100644
--- a/libsolidity/interface/OptimiserSettings.h
+++ b/libsolidity/interface/OptimiserSettings.h
@@ -43,7 +43,7 @@ struct OptimiserSettings
"Tpeul" // Run functional expression inliner
"xarulrul" // Prune a bit more in SSA
- "xarrcL" // Turn into SSA again and simplify
+ "xarrcSL" // Turn into SSA again and simplify
"gvif" // Run full inliner
"CTUcarrLsTFOtfDncarrIulc" // SSA plus simplify
"]"
diff --git a/libyul/CMakeLists.txt b/libyul/CMakeLists.txt
index d8bd02842..2da2a8e54 100644
--- a/libyul/CMakeLists.txt
+++ b/libyul/CMakeLists.txt
@@ -162,6 +162,8 @@ add_library(yul
optimiser/ReasoningBasedSimplifier.h
optimiser/RedundantAssignEliminator.cpp
optimiser/RedundantAssignEliminator.h
+ optimiser/RedundantStoreEliminator.cpp
+ optimiser/RedundantStoreEliminator.h
optimiser/Rematerialiser.cpp
optimiser/Rematerialiser.h
optimiser/SSAReverser.cpp
diff --git a/libyul/optimiser/RedundantStoreEliminator.cpp b/libyul/optimiser/RedundantStoreEliminator.cpp
new file mode 100644
index 000000000..1c1bb72dc
--- /dev/null
+++ b/libyul/optimiser/RedundantStoreEliminator.cpp
@@ -0,0 +1,83 @@
+/*
+ This file is part of solidity.
+
+ solidity is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ solidity is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with solidity. If not, see .
+*/
+// SPDX-License-Identifier: GPL-3.0
+/**
+ */
+
+#include
+
+#include
+#include
+
+#include
+
+#include
+
+using namespace std;
+using namespace solidity;
+using namespace solidity::yul;
+
+
+void RedundantStoreEliminator::run(OptimiserStepContext& _context, Block& _ast)
+{
+ RedundantStoreEliminator rse{_context.dialect};
+ rse(_ast);
+}
+
+void RedundantStoreEliminator::operator()(Block& _block)
+{
+ // TODO This is copied from DataflowAnalyzer
+ size_t numScopes = m_variableScopes.size();
+ pushScope(false);
+
+ map latestStore;
+ set redundantStores;
+
+ for (size_t i = 0; i < _block.statements.size(); ++i)
+ {
+ Statement& statement = _block.statements.at(i);
+ if (holds_alternative(statement))
+ {
+ ExpressionStatement& exprStatement = get(statement);
+ // This mechanism relies on the way the data flow analyzer
+ // handles `m_storage`.
+ if (auto vars = isSimpleStore(StoreLoadLocation::Storage, exprStatement))
+ {
+ if (m_storage.count(vars->first) && latestStore.count(vars->first))
+ redundantStores.insert(latestStore.at(vars->first));
+ latestStore[vars->first] = i;
+ }
+ }
+ ASTModifier::visit(statement);
+ }
+
+ popScope();
+ assertThrow(numScopes == m_variableScopes.size(), OptimizerException, "");
+ DataFlowAnalyzer::operator()(_block);
+ if (redundantStores.empty())
+ return;
+
+ // The arguments to sstore are identifiers and thus do not have side-effects,
+ // because otherwise the statement would not have ended up in `redundantStores`.
+ vector newStatements;
+ for (size_t i = 0; i < _block.statements.size(); ++i)
+ {
+ if (!redundantStores.count(i))
+ newStatements.emplace_back(move(_block.statements.at(i)));
+ }
+ _block.statements = move(newStatements);
+}
diff --git a/libyul/optimiser/RedundantStoreEliminator.h b/libyul/optimiser/RedundantStoreEliminator.h
new file mode 100644
index 000000000..f4ec097e6
--- /dev/null
+++ b/libyul/optimiser/RedundantStoreEliminator.h
@@ -0,0 +1,54 @@
+/*
+ This file is part of solidity.
+
+ solidity is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ solidity is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with solidity. If not, see .
+*/
+// SPDX-License-Identifier: GPL-3.0
+/**
+ */
+
+#pragma once
+
+#include
+#include
+#include
+#include
+
+#include