Skip to content

Commit

Permalink
ConstProp: defer initialization
Browse files Browse the repository at this point in the history
for blocks that don't need pooling. hopefully that's most of them.

Signed-off-by: Alyssa Rosenzweig <[email protected]>
  • Loading branch information
alyssarosenzweig committed Oct 2, 2024
1 parent 541eb91 commit 7c91357
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions FEXCore/Source/Interface/IR/Passes/ConstProp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ class ConstProp final : public FEXCore::IR::Pass {
// Constants are pooled per block.
void ConstProp::HandleConstantPools(IREmitter* IREmit, const IRListView& CurrentIR) {
const uint32_t SSACount = CurrentIR.GetSSACount();
fextl::vector<Ref> Remap(SSACount, NULL);

// Allocation/initialization deferred until first use, since many multiblocks
// don't have constants leftover after all inlining.
fextl::vector<Ref> Remap {};

for (auto [BlockNode, BlockIROp] : CurrentIR.GetBlocks()) {
for (auto [CodeNode, IROp] : CurrentIR.GetCode(BlockNode)) {
Expand All @@ -151,11 +154,15 @@ void ConstProp::HandleConstantPools(IREmitter* IREmit, const IRListView& Current
uint32_t Value = CurrentIR.GetID(CodeNode).Value;
LOGMAN_THROW_A_FMT(Value < SSACount, "def not yet remapped");

if (Remap.empty()) {
Remap.resize(SSACount, NULL);
}

Remap[Value] = it->second;
} else {
ConstPool[Op->Constant] = CodeNode;
}
} else {
} else if (!Remap.empty()) {
const uint8_t NumArgs = IR::GetArgs(IROp->Op);
for (uint8_t i = 0; i < NumArgs; ++i) {
if (IROp->Args[i].IsInvalid()) {
Expand Down

0 comments on commit 7c91357

Please sign in to comment.