diff options
| author | Yong He <yonghe@outlook.com> | 2023-03-22 21:16:35 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-22 21:16:35 -0700 |
| commit | 259a015feb9d4ab65e8fbba32f6c777e92780cc7 (patch) | |
| tree | 45bd4cb9217325c67f5a27d8562b0e7e6b79bb77 /source/slang/slang-ir-simplify-cfg.cpp | |
| parent | d4f99c8bac8b28f18c864a717d8833db6a1c872d (diff) | |
Type legalization and autodiff bug fixes. (#2722)
* Bug fixes.
* Fix.
* Only perform autodiff for functions whose derivative is actually used.
* Fix loop optimize bug.
* Fix high order diff.
* Fix trivial diff func generation.
* Fixes.
* Cleanup.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ir-simplify-cfg.cpp')
| -rw-r--r-- | source/slang/slang-ir-simplify-cfg.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/source/slang/slang-ir-simplify-cfg.cpp b/source/slang/slang-ir-simplify-cfg.cpp index b814442fa..e98d14a0c 100644 --- a/source/slang/slang-ir-simplify-cfg.cpp +++ b/source/slang/slang-ir-simplify-cfg.cpp @@ -105,7 +105,7 @@ static bool doesLoopHasSideEffect(IRGlobalValueWithCode* func, IRLoop* loopInst) loopBlocks.Add(b); auto addressHasOutOfLoopUses = [&](IRInst* addr) { - // The entire access chain of `addr` must have no uses out side the loop. + // The entire access chain of `addr` must have no uses outside the loop. // The root variable must be a local var. for (auto chainNode = addr; chainNode;) { @@ -123,6 +123,11 @@ static bool doesLoopHasSideEffect(IRGlobalValueWithCode* func, IRLoop* loopInst) chainNode = chainNode->getOperand(0); continue; case kIROp_Var: + if (auto rate = chainNode->getFullType()->getRate()) + { + if (!as<IRConstExprRate>(rate)) + return true; + } break; default: return true; @@ -143,10 +148,6 @@ static bool doesLoopHasSideEffect(IRGlobalValueWithCode* func, IRLoop* loopInst) return true; } - // The inst can't possibly have side effect? Skip it. - if (!inst->mightHaveSideEffects()) - continue; - // This inst might have side effect, try to prove that the // side effect does not leak beyond the scope of the loop. if (auto call = as<IRCall>(inst)) @@ -187,6 +188,10 @@ static bool doesLoopHasSideEffect(IRGlobalValueWithCode* func, IRLoop* loopInst) } else { + // The inst can't possibly have side effect? Skip it. + if (!inst->mightHaveSideEffects()) + continue; + // For all other insts, we assume it has a global side effect. return true; } |
