summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-ir-peephole.cpp
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2023-11-14 01:02:08 +0800
committerGitHub <noreply@github.com>2023-11-13 09:02:08 -0800
commitc71b12775c8b13ea2b181e42c04b8db55b10fb2f (patch)
treec041e4f55f4e6d916638aefe021b05a756603d1c /source/slang/slang-ir-peephole.cpp
parent011d4281647e3a2a3cf0dbdda1fa65cc1b8ed881 (diff)
Fix Phi simplification bug (#3325)
Fixes https://github.com/shader-slang/slang/issues/3323
Diffstat (limited to 'source/slang/slang-ir-peephole.cpp')
-rw-r--r--source/slang/slang-ir-peephole.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/source/slang/slang-ir-peephole.cpp b/source/slang/slang-ir-peephole.cpp
index d7713618e..6cabbe8d4 100644
--- a/source/slang/slang-ir-peephole.cpp
+++ b/source/slang/slang-ir-peephole.cpp
@@ -845,8 +845,11 @@ struct PeepholeContext : InstPassBase
{
if (inst->hasUses())
{
- // Is argValue a global constant?
- if (isChildInstOf(inst, argValue->getParent()))
+ // Is argValue not a local value, i.e. it's not a child
+ // of a block, and it's 'visible' from inst because
+ // inst is a descendent of argValue's parent
+ if (!as<IRBlock>(argValue->getParent())
+ && isChildInstOf(inst, argValue->getParent()))
{
inst->replaceUsesWith(argValue);
// Never remove param inst.