mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-05 22:41:25 +12:00
SPU LLVM: sink stores deeper in custom LICM pass
This commit is contained in:
parent
6555de6ef5
commit
1041284384
1 changed files with 38 additions and 3 deletions
|
@ -5596,7 +5596,7 @@ public:
|
||||||
for (u32 i = 0; i < 128; i++)
|
for (u32 i = 0; i < 128; i++)
|
||||||
{
|
{
|
||||||
// If store isn't erased, try to sink it
|
// If store isn't erased, try to sink it
|
||||||
if (auto& bs = block_q[bi]->store[i])
|
if (auto& bs = block_q[bi]->store[i]; bs && block_q[bi]->bb->targets.size() > 1)
|
||||||
{
|
{
|
||||||
std::map<u32, block_info*, std::greater<>> sucs;
|
std::map<u32, block_info*, std::greater<>> sucs;
|
||||||
|
|
||||||
|
@ -5614,10 +5614,15 @@ public:
|
||||||
{
|
{
|
||||||
auto ins = b2->block->getFirstNonPHI();
|
auto ins = b2->block->getFirstNonPHI();
|
||||||
|
|
||||||
if (b2 != block_q[bi] && pdt.dominates(ins, bs) && dt.dominates(bs->getOperand(0), ins))
|
if (b2 != block_q[bi])
|
||||||
{
|
{
|
||||||
if (b2->bb->preds.size() == 1)
|
if (b2->bb->preds.size() == 1)
|
||||||
{
|
{
|
||||||
|
if (!dt.dominates(bs->getOperand(0), ins))
|
||||||
|
continue;
|
||||||
|
if (!pdt.dominates(ins, bs))
|
||||||
|
continue;
|
||||||
|
|
||||||
m_ir->SetInsertPoint(ins);
|
m_ir->SetInsertPoint(ins);
|
||||||
auto si = llvm::cast<StoreInst>(m_ir->Insert(bs->clone()));
|
auto si = llvm::cast<StoreInst>(m_ir->Insert(bs->clone()));
|
||||||
if (b2->store[i] == nullptr)
|
if (b2->store[i] == nullptr)
|
||||||
|
@ -5637,12 +5642,42 @@ public:
|
||||||
auto& edge = block_q[bi]->block_edges[a2];
|
auto& edge = block_q[bi]->block_edges[a2];
|
||||||
if (!edge)
|
if (!edge)
|
||||||
{
|
{
|
||||||
edge = llvm::SplitEdge(block_q[bi]->block_end, b2->block);
|
const auto succ_range = llvm::successors(block_q[bi]->block_end);
|
||||||
|
|
||||||
|
auto succ = b2->block;
|
||||||
|
|
||||||
|
std::vector<llvm::BasicBlock*> succ_q{b2->block};
|
||||||
|
|
||||||
|
for (usz j = 0; j < succ_q.size(); j++)
|
||||||
|
{
|
||||||
|
if (!llvm::count(succ_range, (succ = succ_q[j])))
|
||||||
|
{
|
||||||
|
for (auto pred : llvm::predecessors(succ))
|
||||||
|
{
|
||||||
|
succ_q.emplace_back(pred);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!llvm::count(succ_range, succ))
|
||||||
|
{
|
||||||
|
// TODO: figure this out
|
||||||
|
spu_log.notice("[%s] Failed successor to 0x%05x", fmt::base57(be_t<u64>{m_hash_start}), a2);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
edge = llvm::SplitEdge(block_q[bi]->block_end, succ);
|
||||||
pdt.recalculate(*m_function);
|
pdt.recalculate(*m_function);
|
||||||
dt.recalculate(*m_function);
|
dt.recalculate(*m_function);
|
||||||
}
|
}
|
||||||
|
|
||||||
ins = edge->getTerminator();
|
ins = edge->getTerminator();
|
||||||
|
if (!dt.dominates(bs->getOperand(0), ins))
|
||||||
|
continue;
|
||||||
if (!pdt.dominates(ins, bs))
|
if (!pdt.dominates(ins, bs))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue