summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-autodiff.cpp
diff options
context:
space:
mode:
authorSai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com>2024-09-30 20:54:24 -0400
committerGitHub <noreply@github.com>2024-09-30 20:54:24 -0400
commit81c015e027aa34f2c43394e21f9c1e2c3f7ff1d1 (patch)
tree182e3e07fe3940c002eca87a60381436b863d1fb /source/slang/slang-ir-autodiff.cpp
parenta5d67ad992823ee0323efef07e97ad11814f2eec (diff)
Fix diagnostics for [PreferRecompute] (#5159)
* Fix diagnostics for [PreferRecompute] * Update dont-warn-on-simple-prefer-recompute.slang * Update slang-ir-autodiff.cpp * Update dont-warn-on-simple-prefer-recompute.slang * Update warn-on-prefer-recompute-side-effects.slang
Diffstat (limited to 'source/slang/slang-ir-autodiff.cpp')
-rw-r--r--source/slang/slang-ir-autodiff.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/source/slang/slang-ir-autodiff.cpp b/source/slang/slang-ir-autodiff.cpp
index 6c729ea63..bed6a68e4 100644
--- a/source/slang/slang-ir-autodiff.cpp
+++ b/source/slang/slang-ir-autodiff.cpp
@@ -2416,9 +2416,15 @@ void checkAutodiffPatterns(
if (auto func = as<IRFunc>(inst))
{
if (func->sourceLoc.isValid() && // Don't diagnose for synthesized functions
- func->findDecoration<IRPreferRecomputeDecoration>() &&
- !func->findDecoration<IRNoSideEffectDecoration>())
+ func->findDecoration<IRPreferRecomputeDecoration>())
{
+ // If we don't have any side-effect behavior, we should warn (note: read-none is a stronger
+ // guarantee than no-side-effect)
+ //
+ if (func->findDecoration<IRNoSideEffectDecoration>() ||
+ func->findDecoration<IRReadNoneDecoration>())
+ continue;
+
auto preferRecomputeDecor = func->findDecoration<IRPreferRecomputeDecoration>();
auto sideEffectBehavior = as<IRIntLit>(preferRecomputeDecor->getOperand(0))->getValue();