summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-peephole.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-ir-peephole.cpp')
-rw-r--r--source/slang/slang-ir-peephole.cpp18
1 files changed, 17 insertions, 1 deletions
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<IRIntLit>(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);