summaryrefslogtreecommitdiff
path: root/src/passes/RemoveUnusedBrs.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/passes/RemoveUnusedBrs.cpp')
-rw-r--r--src/passes/RemoveUnusedBrs.cpp16
1 files changed, 4 insertions, 12 deletions
diff --git a/src/passes/RemoveUnusedBrs.cpp b/src/passes/RemoveUnusedBrs.cpp
index 434b8a4bd..785b1c92e 100644
--- a/src/passes/RemoveUnusedBrs.cpp
+++ b/src/passes/RemoveUnusedBrs.cpp
@@ -122,6 +122,8 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> {
} else if (curr->is<Nop>()) {
// ignore (could be result of a previous cycle)
self->valueCanFlow = false;
+ } else if (curr->is<Loop>()) {
+ // do nothing - it's ok for values to flow out
} else {
// anything else stops the flow
flows.clear();
@@ -323,10 +325,7 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> {
// map of all value-less breaks going to a block (and not a loop)
std::map<Block*, std::vector<Break*>> breaksToBlock;
- // number of definitions of each name - when a name is defined more than once, it is not trivially safe to do this
- std::map<Name, Index> numDefs;
-
- // the names to update, when we can (just one def)
+ // the names to update
std::map<Break*, Name> newNames;
void visitBreak(Break* curr) {
@@ -338,8 +337,6 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> {
}
// TODO: Switch?
void visitBlock(Block* curr) {
- if (curr->name.is()) numDefs[curr->name]++;
-
auto& list = curr->list;
if (list.size() == 1 && curr->name.is()) {
// if this block has just one child, a sub-block, then jumps to the former are jumps to us, really
@@ -372,17 +369,12 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> {
}
}
}
- void visitLoop(Loop* curr) {
- if (curr->name.is()) numDefs[curr->name]++;
- }
void finish() {
for (auto& iter : newNames) {
auto* br = iter.first;
auto name = iter.second;
- if (numDefs[name] == 1) {
- br->name = name;
- }
+ br->name = name;
}
}
};