summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com>2023-07-20 18:59:51 -0400
committerGitHub <noreply@github.com>2023-07-20 15:59:51 -0700
commite0a856b8f101ad66159fa9779c36fcc723f611f6 (patch)
treec90582316596be58413a613252af57319a1fb54d
parentc7c493478e5fe88768de8c0e787e1ab993e693c7 (diff)
Fix issue with loop elimination not working on certain side-effect-free loops (#3005)
Co-authored-by: Yong He <yonghe@outlook.com>
-rw-r--r--source/slang/slang-ir-simplify-cfg.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/source/slang/slang-ir-simplify-cfg.cpp b/source/slang/slang-ir-simplify-cfg.cpp
index ab332fd1b..c4c5b584e 100644
--- a/source/slang/slang-ir-simplify-cfg.cpp
+++ b/source/slang/slang-ir-simplify-cfg.cpp
@@ -176,7 +176,9 @@ static bool doesLoopHasSideEffect(IRGlobalValueWithCode* func, IRLoop* loopInst)
if (auto call = as<IRCall>(inst))
{
auto callee = getResolvedInstForDecorations(call->getCallee());
- if (!callee || !callee->findDecoration<IRReadNoneDecoration>())
+ if (!callee ||
+ !(callee->findDecoration<IRNoSideEffectDecoration>() ||
+ callee->findDecoration<IRReadNoneDecoration>()))
return true;
// We are calling a pure function, check if any of the return
// variables are used outside the loop.