diff --git a/mlir/lib/Dialect/SCF/SCF.cpp b/mlir/lib/Dialect/SCF/SCF.cpp --- a/mlir/lib/Dialect/SCF/SCF.cpp +++ b/mlir/lib/Dialect/SCF/SCF.cpp @@ -708,7 +708,9 @@ } else { // If the condition isn't constant, both regions may be executed. regions.push_back(RegionSuccessor(&thenRegion())); - regions.push_back(RegionSuccessor(elseRegion)); + // If the else region does not exist, it is not a viable successor. + if (elseRegion) + regions.push_back(RegionSuccessor(elseRegion)); return; }