Skip to content

Commit 2fa35d6

Browse files
authored
[NFC] Simplify a bit of logic in RemoveUnusedBrs (#8603)
The checks in the old code were not needed: we have a block that has a single child, another block. Any branch to the child sends a value that flows out to the parent immediately. No circumstances exist in which we can error. (block $outer (block $inner ..code and a br to $inner, which can branch to $outer instead.. ) ) Also, this code only handles blocks *without* a value, so even subtyping is not an issue here. (Merging blocks with different types is handled elsewhere, RemoveUnusedNames, so no need to add new logic here.)
1 parent fc43f0d commit 2fa35d6

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/passes/RemoveUnusedBrs.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,11 +1224,7 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> {
12241224
// if this block has just one child, a sub-block, then jumps to the
12251225
// former are jumps to us, really
12261226
if (auto* child = list[0]->dynCast<Block>()) {
1227-
// the two blocks must have the same type for us to update the
1228-
// branch, as otherwise one block may be unreachable and the other
1229-
// concrete, so one might lack a value
1230-
if (child->name.is() && child->name != curr->name &&
1231-
child->type == curr->type) {
1227+
if (child->name.is()) {
12321228
redirectBranches(child, curr->name);
12331229
}
12341230
}

0 commit comments

Comments
 (0)