summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-ir-autodiff-loop-analysis.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/source/slang/slang-ir-autodiff-loop-analysis.cpp b/source/slang/slang-ir-autodiff-loop-analysis.cpp
index 137ab7775..b53b014dd 100644
--- a/source/slang/slang-ir-autodiff-loop-analysis.cpp
+++ b/source/slang/slang-ir-autodiff-loop-analysis.cpp
@@ -707,8 +707,28 @@ StatementSet propagateUpwards(
}
else
{
- // Panic
- SLANG_UNREACHABLE("Unreachable block in conditional branch");
+ // It's possible that the predecessor block is the condition block itself (when
+ // either the true side or the false side is empty).
+ //
+ if (predecessor == ifElse->getParent() && ifElse->getFalseBlock() == current)
+ {
+ // True branch
+ newPredicateSet.conjunct(
+ tryExtractStatements(ifElse, ifElse->getFalseBlock()));
+ }
+ else if (
+ predecessor == ifElse->getParent() && ifElse->getTrueBlock() == current)
+ {
+ // False branch
+ newPredicateSet.conjunct(
+ tryExtractStatements(ifElse, ifElse->getTrueBlock()));
+ }
+ else
+ {
+
+ // Panic
+ SLANG_UNREACHABLE("Unreachable block in conditional branch");
+ }
}
}
}