From 46a4d98baa1d43b33717b4377aefeeaf46b9c2ff Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 23 Jan 2023 06:59:25 -0800 Subject: Full address insts elimination for backward autodiff. (#2604) Co-authored-by: Yong He --- source/slang/slang-ir-single-return.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'source/slang/slang-ir-single-return.cpp') diff --git a/source/slang/slang-ir-single-return.cpp b/source/slang/slang-ir-single-return.cpp index f76e35040..30e933133 100644 --- a/source/slang/slang-ir-single-return.cpp +++ b/source/slang/slang-ir-single-return.cpp @@ -91,4 +91,20 @@ void convertFuncToSingleReturnForm(IRModule* irModule, IRGlobalValueWithCode* fu context.processFunc(func); } +bool isSingleReturnFunc(IRGlobalValueWithCode* func) +{ + int returnCount = 0; + for (auto block : func->getBlocks()) + { + for (auto inst : block->getChildren()) + { + if (inst->getOp() == kIROp_Return) + { + returnCount++; + } + } + } + return returnCount <= 1; +} + } // namespace Slang -- cgit v1.2.3