diff options
| author | Sai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com> | 2024-10-28 15:47:58 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-28 15:47:58 -0400 |
| commit | b61be5e6fb7fe1c4ec8228cdf73f49f11e5a0ac9 (patch) | |
| tree | 0e392546b41a55d36a874f2a82110867e6dd422c /source/slang/slang-ir-util.cpp | |
| parent | 0557a199d2eb205bf133c8fc111cce3a19336fde (diff) | |
Assorted auto-diff enhancements for increased performance & more streamlined auto-diff results (#5394)
* Various AD enhancements
* Fix issue with pt-loop test
* Update pt-loop.slang
* More fixes for perf. Final minimal context test now passes.
* Fix issue with loop-elimination pass not running after dce
* Try fix wgpu test by removing select operator
* Disable wgpu
* Delete out.wgsl
* Remove comments
* Update slang-ir-util.cpp
* Fix header relative paths for slang-embed
* Disbale wgpu for a few other tests
* Better way of determining which params to ignore for side-effects
* Update slang-ir-dce.cpp
* Fix issue with circular reference from previous AD pass being left behind for the next AD pass
* Update slang-ir-dce.cpp
Diffstat (limited to 'source/slang/slang-ir-util.cpp')
| -rw-r--r-- | source/slang/slang-ir-util.cpp | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/source/slang/slang-ir-util.cpp b/source/slang/slang-ir-util.cpp index f81cde30b..b0eeca4dd 100644 --- a/source/slang/slang-ir-util.cpp +++ b/source/slang/slang-ir-util.cpp @@ -971,12 +971,41 @@ void setInsertAfterOrdinaryInst(IRBuilder* builder, IRInst* inst) } } +IRInst* tryFindBasePtr(IRInst* inst, IRInst* parentFunc) +{ + // Keep going up the tree until we find a variable. + switch (inst->getOp()) + { + case kIROp_Var: + return getParentFunc(inst) == parentFunc ? inst : nullptr; + case kIROp_Param: + return getParentFunc(inst) == parentFunc ? inst : nullptr; + case kIROp_GetElementPtr: + return tryFindBasePtr(as<IRGetElementPtr>(inst)->getBase(), parentFunc); + case kIROp_FieldAddress: + return tryFindBasePtr(as<IRFieldAddress>(inst)->getBase(), parentFunc); + default: + return nullptr; + } +} + bool areCallArgumentsSideEffectFree(IRCall* call, SideEffectAnalysisOptions options) { // If the function has no side effect and is not writing to any outputs, // we can safely treat the call as a normal inst. + IRFunc* parentFunc = nullptr; - for (UInt i = 0; i < call->getArgCount(); i++) + + IRParam* param = nullptr; + if (auto calleeFunc = getResolvedInstForDecorations(call->getCallee())) + { + if (auto block = calleeFunc->getFirstBlock()) + { + param = block->getFirstParam(); + } + } + + for (UInt i = 0; i < call->getArgCount(); i++, (param = param ? param->getNextParam() : nullptr)) { auto arg = call->getArg(i); if (isValueType(arg->getDataType())) @@ -1074,6 +1103,9 @@ bool areCallArgumentsSideEffectFree(IRCall* call, SideEffectAnalysisOptions opti } else { + if (param && param->findDecoration<IRIgnoreSideEffectsDecoration>()) + continue; + return false; } } @@ -1107,6 +1139,7 @@ bool doesCalleeHaveSideEffect(IRInst* callee) { case kIROp_NoSideEffectDecoration: case kIROp_ReadNoneDecoration: + case kIROp_IgnoreSideEffectsDecoration: return false; } } |
