From 78517dc392f0d2ebba25f0ac3f4d4e004b0f0ab0 Mon Sep 17 00:00:00 2001 From: Sai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com> Date: Fri, 14 Mar 2025 17:15:36 -0700 Subject: Fix lowering of associated types in generic interfaces (#6600) * Fix lowering of associated types in generic interfaces. * Update diff-assoctype-generic-interface.slang * Fix-up lowering of differentiable witnesses for implicit ops * Update slang-ir-autodiff-transcriber-base.cpp * Fix issue with differentiating type-packs --- source/slang/slang-ir-autodiff.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source/slang/slang-ir-autodiff.cpp') diff --git a/source/slang/slang-ir-autodiff.cpp b/source/slang/slang-ir-autodiff.cpp index df657476a..f3f32add2 100644 --- a/source/slang/slang-ir-autodiff.cpp +++ b/source/slang/slang-ir-autodiff.cpp @@ -1362,9 +1362,10 @@ IRInst* DifferentiableTypeConformanceContext::lookUpInterfaceMethod( IRBuilder* builder, IRType* origType, IRStructKey* key, - IRType* resultType) + IRType* resultType, + DiffConformanceKind kind) { - if (auto conformance = tryGetDifferentiableWitness(builder, origType, DiffConformanceKind::Any)) + if (auto conformance = tryGetDifferentiableWitness(builder, origType, kind)) return _lookupWitness(builder, conformance, key, resultType); return nullptr; } @@ -2097,8 +2098,6 @@ IRInst* DifferentiableTypeConformanceContext::buildTupleWitness( IRWitnessTable* table = nullptr; if (target == DiffConformanceKind::Value) { - SLANG_ASSERT(isDifferentiableValueType((IRType*)inTupleType)); - auto addMethod = builder->createFunc(); auto zeroMethod = builder->createFunc(); @@ -2138,6 +2137,8 @@ IRInst* DifferentiableTypeConformanceContext::buildTupleWitness( &b, (IRType*)elementType, DiffConformanceKind::Value); + + SLANG_ASSERT(isDifferentiableValueType((IRType*)elementType)); IRInst* elementResult = nullptr; if (!innerWitness) { @@ -2171,9 +2172,9 @@ IRInst* DifferentiableTypeConformanceContext::buildTupleWitness( { // Zero method. IRBuilder b = *builder; - b.setInsertInto(addMethod); - b.addBackwardDifferentiableDecoration(addMethod); - addMethod->setFullType(b.getFuncType(0, nullptr, diffTupleType)); + b.setInsertInto(zeroMethod); + b.addBackwardDifferentiableDecoration(zeroMethod); + zeroMethod->setFullType(b.getFuncType(0, nullptr, diffTupleType)); b.emitBlock(); List results; for (UInt i = 0; i < inTupleType->getOperandCount(); i++) @@ -2214,7 +2215,6 @@ IRInst* DifferentiableTypeConformanceContext::buildTupleWitness( else if (target == DiffConformanceKind::Ptr) { SLANG_ASSERT(isDifferentiablePtrType((IRType*)inTupleType)); - table = builder->createWitnessTable( sharedContext->differentiablePtrInterfaceType, (IRType*)inTupleType); -- cgit v1.2.3