From cbc1eff56057f199183bb7c17d8a360326512367 Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 1 Nov 2022 08:46:57 -0700 Subject: Make `DifferentialPair` able to nest. (#2477) --- source/slang/slang-ir.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'source/slang/slang-ir.cpp') diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp index 3a59eb6c9..382f7be5e 100644 --- a/source/slang/slang-ir.cpp +++ b/source/slang/slang-ir.cpp @@ -3629,6 +3629,7 @@ namespace Slang IRInst* IRBuilder::findDifferentiableTypeEntry(IRInst* irType, IRInst* scope) { + IRInst* foundResult = nullptr; for (auto child = scope->getFirstChild(); child; child = child->getNextInst()) { if (child->getOp() == kIROp_DifferentiableTypeDictionary) @@ -3640,13 +3641,20 @@ namespace Slang if (irType == entryType) { - return entryConformanceWitness; + foundResult = entryConformanceWitness; + // If the found witness table is not a trivial one (i.e. DifferentialBottom:IDifferential), + // return immediately. Otherwise, continue the search to see if we can find a better one. + if (auto witness = as(foundResult)) + { + if (witness->getConcreteType()->getOp() != kIROp_DifferentialBottomType) + return foundResult; + } } } } } - return nullptr; + return foundResult; } IRInst* IRBuilder::findDifferentiableTypeEntry(IRInst* irType) @@ -6282,6 +6290,8 @@ namespace Slang case kIROp_MakeOptionalNone: case kIROp_OptionalHasValue: case kIROp_GetOptionalValue: + case kIROp_MakeTuple: + case kIROp_GetTupleElement: case kIROp_Load: // We are ignoring the possibility of loads from bad addresses, or `volatile` loads case kIROp_ImageSubscript: case kIROp_FieldExtract: -- cgit v1.2.3