Tune Rematerializer

This commit is contained in:
chriseth
2020-01-08 09:56:08 +01:00
parent d1a7ff0fbc
commit 25d3f27c11
12 changed files with 159 additions and 12 deletions
+6 -1
View File
@@ -78,7 +78,12 @@ void Rematerialiser::visit(Expression& _e)
auto const& value = *m_value.at(name);
size_t refs = m_referenceCounts[name];
size_t cost = CodeCost::codeCost(m_dialect, value);
if (refs <= 1 || cost == 0 || (refs <= 5 && cost <= 1) || m_varsToAlwaysRematerialize.count(name))
if (
(refs <= 1 && m_variableLoopDepth.at(name) == m_loopDepth) ||
cost == 0 ||
(refs <= 5 && cost <= 1) ||
m_varsToAlwaysRematerialize.count(name)
)
{
assertThrow(m_referenceCounts[name] > 0, OptimizerException, "");
for (auto const& ref: m_references.forward[name])