diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/OptimizeInstructions.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp index c9e1ced19..f5a0c6756 100644 --- a/src/passes/OptimizeInstructions.cpp +++ b/src/passes/OptimizeInstructions.cpp @@ -1632,7 +1632,12 @@ struct OptimizeInstructions } if (auto* select = ref->dynCast<Select>()) { - if (select->ifTrue->type.isNull()) { + // We must check for unreachability explicitly here because a full + // refinalize only happens at the end. That is, the select may stil be + // reachable after we turned one child into an unreachable, and we are + // calling getResultOfFirst which will error on unreachability. + if (select->ifTrue->type.isNull() && + select->ifFalse->type != Type::unreachable) { ref = builder.makeSequence( builder.makeDrop(select->ifTrue), getResultOfFirst(select->ifFalse, |