mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-04 16:32:39 +00:00
control_flow: Avoid adding unnecessary divergant blocks
This commit is contained in:
parent
6244d00795
commit
29b51567ea
@ -47,6 +47,15 @@ static IR::Condition MakeCondition(const GcnInst& inst) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool IgnoresExecMask(Opcode opcode) {
|
||||||
|
switch (opcode) {
|
||||||
|
case Opcode::V_WRITELANE_B32:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static constexpr size_t LabelReserveSize = 32;
|
static constexpr size_t LabelReserveSize = 32;
|
||||||
|
|
||||||
CFG::CFG(Common::ObjectPool<Block>& block_pool_, std::span<const GcnInst> inst_list_)
|
CFG::CFG(Common::ObjectPool<Block>& block_pool_, std::span<const GcnInst> inst_list_)
|
||||||
@ -133,20 +142,24 @@ void CFG::EmitDivergenceLabels() {
|
|||||||
curr_begin = -1;
|
curr_begin = -1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Add a label to the instruction right after the open scope call.
|
// If all instructions in the scope ignore exec masking, we shouldn't insert a scope.
|
||||||
// It is the start of a new basic block.
|
const auto start = inst_list.begin() + curr_begin + 1;
|
||||||
const auto& save_inst = inst_list[curr_begin];
|
if (!std::ranges::all_of(start, inst_list.begin() + index, IgnoresExecMask, &GcnInst::opcode)) {
|
||||||
const Label label = index_to_pc[curr_begin] + save_inst.length;
|
// Add a label to the instruction right after the open scope call.
|
||||||
AddLabel(label);
|
// It is the start of a new basic block.
|
||||||
// Add a label to the close scope instruction.
|
const auto& save_inst = inst_list[curr_begin];
|
||||||
// There are 3 cases where we need to close a scope.
|
const Label label = index_to_pc[curr_begin] + save_inst.length;
|
||||||
// * Close scope instruction inside the block
|
AddLabel(label);
|
||||||
// * Close scope instruction at the end of the block (cbranch or endpgm)
|
// Add a label to the close scope instruction.
|
||||||
// * Normal instruction at the end of the block
|
// There are 3 cases where we need to close a scope.
|
||||||
// For the last case we must NOT add a label as that would cause
|
// * Close scope instruction inside the block
|
||||||
// the instruction to be separated into its own basic block.
|
// * Close scope instruction at the end of the block (cbranch or endpgm)
|
||||||
if (is_close) {
|
// * Normal instruction at the end of the block
|
||||||
AddLabel(index_to_pc[index]);
|
// For the last case we must NOT add a label as that would cause
|
||||||
|
// the instruction to be separated into its own basic block.
|
||||||
|
if (is_close) {
|
||||||
|
AddLabel(index_to_pc[index]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Reset scope begin.
|
// Reset scope begin.
|
||||||
curr_begin = -1;
|
curr_begin = -1;
|
||||||
|
@ -702,7 +702,7 @@ Liverpool::Task Liverpool::ProcessCompute(std::span<const u32> acb, int vqid) {
|
|||||||
false);
|
false);
|
||||||
} else if (dma_data->src_sel == DmaDataSrc::Gds &&
|
} else if (dma_data->src_sel == DmaDataSrc::Gds &&
|
||||||
dma_data->dst_sel == DmaDataDst::Memory) {
|
dma_data->dst_sel == DmaDataDst::Memory) {
|
||||||
LOG_WARNING(Render_Vulkan, "GDS memory read");
|
// LOG_WARNING(Render_Vulkan, "GDS memory read");
|
||||||
} else if (dma_data->src_sel == DmaDataSrc::Memory &&
|
} else if (dma_data->src_sel == DmaDataSrc::Memory &&
|
||||||
dma_data->dst_sel == DmaDataDst::Memory) {
|
dma_data->dst_sel == DmaDataDst::Memory) {
|
||||||
rasterizer->InlineData(dma_data->DstAddress<VAddr>(),
|
rasterizer->InlineData(dma_data->DstAddress<VAddr>(),
|
||||||
|
Loading…
Reference in New Issue
Block a user