diff options
| author | Yong He <yonghe@outlook.com> | 2023-10-04 11:20:35 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-04 11:20:35 -0700 |
| commit | ac886fd3e329a9599ed1ac7a6d8b26ca5821046c (patch) | |
| tree | 87bcafb3985775f9d90303d6a4239eb743164407 /source/slang/slang-ir-array-reg-to-mem.cpp | |
| parent | d87493a46c00be37b820a473c0827bbb865eb222 (diff) | |
SPIRV compiler performance fixes. (#3258)
* SPIRV compiler performance fixes.
* Cleanup.
* update project files
* Cleanup debug code.
* Make redundancy removal non-recursive.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ir-array-reg-to-mem.cpp')
| -rw-r--r-- | source/slang/slang-ir-array-reg-to-mem.cpp | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/source/slang/slang-ir-array-reg-to-mem.cpp b/source/slang/slang-ir-array-reg-to-mem.cpp deleted file mode 100644 index 34bd5b148..000000000 --- a/source/slang/slang-ir-array-reg-to-mem.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include "slang-ir-array-reg-to-mem.h" - -#include "slang-ir.h" -#include "slang-ir-insts.h" -#include "slang-ir-util.h" - -namespace Slang -{ - bool eliminateArrayTypeParameters(IRFunc* func) - { - IRBuilder builder(func); - bool changed = false; - List<UInt> arrayParamIds; - UInt idx = 0; - List<IRParam*> paramWorkList; - for (auto param : func->getParams()) - { - if (auto arrayType = as<IRArrayTypeBase>(param->getFullType())) - { - paramWorkList.add(param); - arrayParamIds.add(idx); - } - idx++; - } - for (auto param : paramWorkList) - { - // We have an array type parameter, so we need to replace it with a pointer to the array - // type. - // - // We will also need to insert a `load` instruction at the start of the function body - // to load the actual pointer value from the parameter. - // - if (auto arrayType = as<IRArrayTypeBase>(param->getFullType())) - { - changed = true; - auto ptrArrayType = builder.getPtrType(arrayType); - auto newParam = builder.createParam(ptrArrayType); - newParam->insertBefore(param); - setInsertAfterOrdinaryInst(&builder, param); - auto regVal = builder.emitLoad(newParam); - param->replaceUsesWith(regVal); - param->removeAndDeallocate(); - } - } - if (changed) - { - // The function is modified, we need to also update its type. - List<IRType*> paramTypes; - for (auto param : func->getParams()) - { - paramTypes.add(param->getFullType()); - } - auto newFuncType = builder.getFuncType((UInt)paramTypes.getCount(), paramTypes.getBuffer(), func->getResultType()); - func->setFullType(newFuncType); - - // Update all the call sites to pass the arrays by pointer. - traverseUses(func, [&](IRUse* use) - { - if (const auto call = as<IRCall>(use->getUser())) - { - builder.setInsertBefore(call); - for (auto paramId : arrayParamIds) - { - auto arg = call->getArg(paramId); - SLANG_ASSERT(as<IRPtrTypeBase>(paramTypes[paramId])); - auto var = builder.emitVar(as<IRPtrTypeBase>(paramTypes[paramId])->getValueType()); - builder.emitStore(var, arg); - call->setArg(paramId, var); - } - } - }); - } - return changed; - } - - bool eliminateArrayTypeSSARegisters(IRModule* module) - { - bool changed = false; - for (auto inst : module->getGlobalInsts()) - { - if (auto func = as<IRFunc>(inst)) - { - changed |= eliminateArrayTypeParameters(func); - } - } - return changed; - } -} |
