Skip to content
Merged
14 changes: 6 additions & 8 deletions src/passes/ConstraintAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
#include <algorithm>

#include "cfg/cfg-traversal.h"
#include "cfg/rpo.h"
#include "cfg/wto.h"
#include "ir/constraint.h"
#include "ir/drop.h"
#include "ir/eh-utils.h"
Expand Down Expand Up @@ -97,7 +97,7 @@ namespace {

// Information in a basic block.
struct Info {
// For RPOQueue
// For WTOWorklist
bool inQueue;
Index index;

Expand Down Expand Up @@ -258,12 +258,10 @@ struct ConstraintAnalysis
}

// Starting from the entry, keep going while we find something new.
RPOQueue<ConstraintAnalysis> work(*this);
WTOWorklist<ConstraintAnalysis> work(*this);
work.push(entry);

while (!work.empty()) {
auto* block = work.pop();

work.run([&](BasicBlock* block) {
// Start at the top of the block, then go through, applying things.
BasicBlockConstraintMap constraints = block->contents.startConstraints;

Expand All @@ -280,7 +278,7 @@ struct ConstraintAnalysis

if (constraints.unreachable) {
// Nothing to send.
continue;
return;
}

#if CONSTRAINT_DEBUG
Expand Down Expand Up @@ -323,7 +321,7 @@ struct ConstraintAnalysis
}
}
}
}
});
}

// If we change types, we must refinalize.
Expand Down
18 changes: 9 additions & 9 deletions src/passes/RedundantSetElimination.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
//

#include <cfg/cfg-traversal.h>
#include <cfg/rpo.h>
#include <cfg/wto.h>
#include <ir/literal-utils.h>
#include <ir/numbering.h>
#include <ir/properties.h>
Expand All @@ -58,7 +58,7 @@ namespace {

// information in a basic block
struct Info {
// For RPOQueue
// For WTOWorklist
bool inQueue;
Index index;

Expand Down Expand Up @@ -225,12 +225,12 @@ struct RedundantSetElimination
end[i] = unseenValue;
}
}
// Keep working while stuff is flowing, in reverse-postorder so that we
// reach code after its predecessors, avoiding wasted recomputation.
RPOQueue<RedundantSetElimination> work(*this);
// Keep working while stuff is flowing, in weak topological order so that we
// reach code after its predecessors and stabilize inner loops before outer
// loops, avoiding wasted recomputation.
WTOWorklist<RedundantSetElimination> work(*this);
work.push(entry);
while (!work.empty()) {
auto* curr = work.pop();
work.run([&](BasicBlock* curr) {
#if RSE_DEBUG
std::cout << "flow block " << curr << '\n';
#endif
Expand Down Expand Up @@ -325,7 +325,7 @@ struct RedundantSetElimination
// note that the first iteration this is always not the case,
// since end contains unseen (and then the comparison ends on
// the first element)
continue;
return;
}
// update the end state and update children
#ifndef NDEBUG
Expand All @@ -342,7 +342,7 @@ struct RedundantSetElimination
for (auto* next : curr->out) {
work.push(next);
}
}
});
}

// optimizing
Expand Down
Loading