From ecf85df6eee3da76ef54b14e4ab083f22da89e46 Mon Sep 17 00:00:00 2001 From: Yong He Date: Sun, 18 Aug 2024 21:57:24 -0700 Subject: Variadic Generics Part 2: IR lowering and specialization. (#4849) * Variadic Generics Part 2: IR lowering and specialization. * Update design doc status. * Update design doc. * Resolve review comments. --- source/slang/slang-ir-peephole.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'source/slang/slang-ir-peephole.cpp') diff --git a/source/slang/slang-ir-peephole.cpp b/source/slang/slang-ir-peephole.cpp index 232633d69..aa8dfddab 100644 --- a/source/slang/slang-ir-peephole.cpp +++ b/source/slang/slang-ir-peephole.cpp @@ -324,7 +324,10 @@ struct PeepholeContext : InstPassBase } break; case kIROp_GetTupleElement: - if (inst->getOperand(0)->getOp() == kIROp_MakeTuple) + switch (inst->getOperand(0)->getOp()) + { + case kIROp_MakeTuple: + case kIROp_MakeWitnessPack: { auto element = inst->getOperand(1); if (auto intLit = as(element)) @@ -333,6 +336,10 @@ struct PeepholeContext : InstPassBase maybeRemoveOldInst(inst); changed = true; } + break; + } + default: + break; } break; case kIROp_FieldExtract: @@ -1181,6 +1188,15 @@ bool peepholeOptimize(TargetProgram* target, IRInst* func) return context.processFunc(func); } +bool peepholeOptimizeInst(TargetProgram* target, IRModule* module, IRInst* inst) +{ + PeepholeContext context = PeepholeContext(module); + context.targetProgram = target; + context.useFastAnalysis = true; + context.processInst(inst); + return context.changed; +} + bool peepholeOptimizeGlobalScope(TargetProgram* target, IRModule* module) { PeepholeContext context = PeepholeContext(module); -- cgit v1.2.3