diff options
| author | Yong He <yonghe@outlook.com> | 2022-12-07 12:02:30 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-07 12:02:30 -0800 |
| commit | 3a3a8b5f7701109fc413f42692c4de5769870489 (patch) | |
| tree | 909df4a30e69f33a76e0158d92b1823629dc2184 /source/slang/slang-ir-inline.cpp | |
| parent | f116f43bd12358e87f351f0d3615628ac4e00921 (diff) | |
Lower-to-ir no longer produce `Construct` inst. (#2553)
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 | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/source/slang/slang-ir-inline.cpp b/source/slang/slang-ir-inline.cpp index f49b52975..36eea8c54 100644 --- a/source/slang/slang-ir-inline.cpp +++ b/source/slang/slang-ir-inline.cpp @@ -198,6 +198,9 @@ struct InliningPassBase // outCallSite.callee = calleeFunc; + if (callee->findDecoration<IRIntrinsicOpDecoration>()) + return true; + // At this point the `CallSiteInfo` is complete and // could be used for inlining, but we have additional // checks to make. @@ -239,6 +242,27 @@ struct InliningPassBase IRBuilder builder(sharedBuilder); builder.setInsertBefore(call); + // If callee is an intrinsic op, just issue that intrinsic and be done. + if (auto intrinsicOpDecor = callee->findDecoration<IRIntrinsicOpDecoration>()) + { + List<IRInst*> args; + for (UInt i = 0; i < call->getArgCount(); i++) + args.add(call->getArg(i)); + auto op = intrinsicOpDecor->getIntrinsicOp(); + if (op == 0) + { + SLANG_RELEASE_ASSERT(call->getArgCount() >= 1); + call->replaceUsesWith(call->getArg(0)); + } + else + { + auto newCall = builder.emitIntrinsicInst(call->getFullType(), op, args.getCount(), args.getBuffer()); + call->replaceUsesWith(newCall); + } + call->removeAndDeallocate(); + return; + } + // If the callee is a generic function, then we will // need to include the substitution of generic parameters // with their argument values in our cloning. @@ -506,6 +530,8 @@ struct MandatoryEarlyInliningPass : InliningPassBase { if(info.callee->findDecoration<IRUnsafeForceInlineEarlyDecoration>()) return true; + if (info.callee->findDecoration<IRIntrinsicOpDecoration>()) + return true; return false; } }; @@ -618,7 +644,8 @@ struct ForceInliningPass : InliningPassBase bool shouldInline(CallSiteInfo const& info) { if (info.callee->findDecoration<IRForceInlineDecoration>() || - info.callee->findDecoration<IRUnsafeForceInlineEarlyDecoration>()) + info.callee->findDecoration<IRUnsafeForceInlineEarlyDecoration>()|| + info.callee->findDecoration<IRIntrinsicOpDecoration>()) return true; return false; } |
