diff options
| author | Yong He <yonghe@outlook.com> | 2023-08-31 13:49:40 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-31 13:49:40 -0700 |
| commit | cc412af89e54b04ead508ca84825a18d001b92d0 (patch) | |
| tree | da7bb020c494cc4dc62a9c641fb88d7b0b9f89f2 /source/slang/slang-ir-inline.cpp | |
| parent | 1996785e1c5d76254a102c1ec0df5dd7e2e4d68a (diff) | |
Add SPIRV atomics intrinsics and fix buffer layout lowering. (#3170)
* Fix atomics intrinsics and buffer layout lowering.
* Fix.
* Add more test.
* Fix.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ir-inline.cpp')
| -rw-r--r-- | source/slang/slang-ir-inline.cpp | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/source/slang/slang-ir-inline.cpp b/source/slang/slang-ir-inline.cpp index 4308d16f0..5479a98ff 100644 --- a/source/slang/slang-ir-inline.cpp +++ b/source/slang/slang-ir-inline.cpp @@ -896,15 +896,39 @@ struct IntrinsicFunctionInliningPass : InliningPassBase auto returnInst = as<IRReturn>(func->getFirstBlock()->getTerminator()); if (!returnInst) return false; - auto firstInst = as<IRSPIRVAsm>(func->getFirstBlock()->getFirstOrdinaryInst()); - return returnInst->getVal() == firstInst; + + // If a function body has only asm blocks + trivial insts (load/store), + // this is considered as a pure asm function, and we can inline it. + bool hasSpvAsm = false; + for (auto inst = func->getFirstBlock()->getFirstOrdinaryInst(); inst != returnInst; inst = inst->getNextInst()) + { + switch (inst->getOp()) + { + case kIROp_SPIRVAsmOperandInst: + case kIROp_SPIRVAsm: + hasSpvAsm = true; + continue; + case kIROp_Load: + case kIROp_swizzle: + case kIROp_Store: + continue; + default: + return false; + } + } + return hasSpvAsm; } }; void performIntrinsicFunctionFunctionInlining(IRModule* module) { IntrinsicFunctionInliningPass pass(module); - pass.considerAllCallSites(); + bool changed = true; + + while (changed) + { + changed = pass.considerAllCallSites(); + } } struct CustomInliningPass : InliningPassBase |
