From f7b9745e46db6a7e55f6e0265493350d65ea4615 Mon Sep 17 00:00:00 2001 From: Sai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com> Date: Tue, 25 Feb 2025 12:04:31 -0800 Subject: Fix a bug with hoisting 'IRVar' insts that are used outside the loop (#6446) * Fix a bug with hoisting 'IRVar' insts that are used outside the loop - We introduce a 'CheckpointObject' inst and use that to split loop state insts into two pieces (one for within-loop uses and one for outside-loop uses. - This allows the two kinds of uses to be handled separately by the hoisting mechanism - CheckpointObject is then lowered to a no-op after hoisting is complete. * Update slang-ir-autodiff-primal-hoist.cpp * Update slang-ir-autodiff-primal-hoist.cpp --- source/slang/slang-ir.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source/slang/slang-ir.cpp') diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp index fb274c4a0..3a7ace37d 100644 --- a/source/slang/slang-ir.cpp +++ b/source/slang/slang-ir.cpp @@ -5664,6 +5664,13 @@ IRInst* IRBuilder::emitDiscard() return inst; } +IRInst* IRBuilder::emitCheckpointObject(IRInst* value) +{ + auto inst = + createInst(this, kIROp_CheckpointObject, value->getFullType(), value); + addInst(inst); + return inst; +} IRInst* IRBuilder::emitBranch(IRBlock* pBlock) { -- cgit v1.2.3