Skip to content

Commit 65f9bbb

Browse files
authored
shader_recompiler: Ignore exec mask for scalar instructions. (#2097)
1 parent 0eee36c commit 65f9bbb

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/shader_recompiler/frontend/control_flow_graph.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,26 @@ static IR::Condition MakeCondition(const GcnInst& inst) {
4747
}
4848
}
4949

50-
static bool IgnoresExecMask(Opcode opcode) {
51-
switch (opcode) {
50+
static bool IgnoresExecMask(const GcnInst& inst) {
51+
// EXEC mask does not affect scalar instructions or branches.
52+
switch (inst.category) {
53+
case InstCategory::ScalarALU:
54+
case InstCategory::ScalarMemory:
55+
case InstCategory::FlowControl:
56+
return true;
57+
default:
58+
break;
59+
}
60+
// Read/Write Lane instructions are not affected either.
61+
switch (inst.opcode) {
62+
case Opcode::V_READLANE_B32:
5263
case Opcode::V_WRITELANE_B32:
64+
case Opcode::V_READFIRSTLANE_B32:
5365
return true;
5466
default:
55-
return false;
67+
break;
5668
}
69+
return false;
5770
}
5871

5972
static constexpr size_t LabelReserveSize = 32;
@@ -147,8 +160,7 @@ void CFG::EmitDivergenceLabels() {
147160
// If all instructions in the scope ignore exec masking, we shouldn't insert a
148161
// scope.
149162
const auto start = inst_list.begin() + curr_begin + 1;
150-
if (!std::ranges::all_of(start, inst_list.begin() + index, IgnoresExecMask,
151-
&GcnInst::opcode)) {
163+
if (!std::ranges::all_of(start, inst_list.begin() + index, IgnoresExecMask)) {
152164
// Add a label to the instruction right after the open scope call.
153165
// It is the start of a new basic block.
154166
const auto& save_inst = inst_list[curr_begin];

0 commit comments

Comments
 (0)