From c71b12775c8b13ea2b181e42c04b8db55b10fb2f Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Tue, 14 Nov 2023 01:02:08 +0800 Subject: Fix Phi simplification bug (#3325) Fixes https://github.com/shader-slang/slang/issues/3323 --- source/slang/slang-ir-peephole.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source') 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(argValue->getParent()) + && isChildInstOf(inst, argValue->getParent())) { inst->replaceUsesWith(argValue); // Never remove param inst. -- cgit v1.2.3