aboutsummaryrefslogtreecommitdiffstats
path: root/libyul/optimiser/Rematerialiser.h
diff options
context:
space:
mode:
Diffstat (limited to 'libyul/optimiser/Rematerialiser.h')
-rw-r--r--libyul/optimiser/Rematerialiser.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/libyul/optimiser/Rematerialiser.h b/libyul/optimiser/Rematerialiser.h
index b3841519..c34353de 100644
--- a/libyul/optimiser/Rematerialiser.h
+++ b/libyul/optimiser/Rematerialiser.h
@@ -26,16 +26,27 @@ namespace yul
{
/**
- * Optimisation stage that replaces variables by their most recently assigned expressions.
+ * Optimisation stage that replaces variables by their most recently assigned expressions,
+ * but only if the expression is movable and one of the following holds:
+ * - the variable is referenced exactly once
+ * - the value is extremely cheap ("cost" of zero like ``caller()``)
+ * - the variable is referenced at most 5 times and the value is rather cheap
+ * ("cost" of at most 1 like a constant up to 0xff)
*
* Prerequisite: Disambiguator
*/
class Rematerialiser: public DataFlowAnalyzer
{
+public:
+ static void run(Block& _ast);
+
protected:
+ Rematerialiser(Block& _ast);
+
using ASTModifier::visit;
void visit(Expression& _e) override;
+ std::map<YulString, size_t> m_referenceCounts;
};
}