summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com>2025-04-24 18:44:01 -0400
committerGitHub <noreply@github.com>2025-04-24 15:44:01 -0700
commitc7ecf3039d2cc8680f1ea5f4bee2d13521ae34f7 (patch)
tree571da991f6031b4676bc1f09ae8d7e3daeaba6ad
parent54fda59f940017c76da29250ce42f945b7544cc8 (diff)
Handle case where either side of a conditional branch is empty (#6890)
Co-authored-by: Yong He <yonghe@outlook.com>
-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");
+ }
}
}
}