yuzu-emu
/
yuzu-android
Archived
1
0
Fork 0

shader: Fix conditional execution of exit instructions

This commit is contained in:
ReinUsesLisp 2021-02-24 18:32:00 -03:00 committed by ameerj
parent 7496bbf758
commit 622d676202
2 changed files with 6 additions and 5 deletions

View File

@ -322,12 +322,13 @@ CFG::AnalysisState CFG::AnalyzeInst(Block* block, FunctionId function_id, Locati
return AnalysisState::Continue; return AnalysisState::Continue;
} }
const IR::Condition cond{static_cast<IR::Pred>(pred.index), pred.negated}; const IR::Condition cond{static_cast<IR::Pred>(pred.index), pred.negated};
AnalyzeCondInst(block, function_id, pc, EndClass::Branch, cond); AnalyzeCondInst(block, function_id, pc, EndClass::Branch, cond, true);
return AnalysisState::Branch; return AnalysisState::Branch;
} }
void CFG::AnalyzeCondInst(Block* block, FunctionId function_id, Location pc, void CFG::AnalyzeCondInst(Block* block, FunctionId function_id, Location pc,
EndClass insn_end_class, IR::Condition cond) { EndClass insn_end_class, IR::Condition cond,
bool visit_conditional_inst) {
if (block->begin != pc) { if (block->begin != pc) {
// If the block doesn't start in the conditional instruction // If the block doesn't start in the conditional instruction
// mark it as a label to visit it later // mark it as a label to visit it later
@ -354,7 +355,7 @@ void CFG::AnalyzeCondInst(Block* block, FunctionId function_id, Location pc,
// Impersonate the visited block with a virtual block // Impersonate the visited block with a virtual block
*block = std::move(virtual_block); *block = std::move(virtual_block);
// Set the end properties of the conditional instruction // Set the end properties of the conditional instruction
conditional_block->end = pc + 1; conditional_block->end = visit_conditional_inst ? (pc + 1) : pc;
conditional_block->end_class = insn_end_class; conditional_block->end_class = insn_end_class;
// Add a label to the instruction after the conditional instruction // Add a label to the instruction after the conditional instruction
Block* const endif_block{AddLabel(conditional_block, block->stack, pc + 1, function_id)}; Block* const endif_block{AddLabel(conditional_block, block->stack, pc + 1, function_id)};
@ -423,7 +424,7 @@ CFG::AnalysisState CFG::AnalyzeEXIT(Block* block, FunctionId function_id, Locati
throw NotImplementedException("Conditional EXIT with PEXIT token"); throw NotImplementedException("Conditional EXIT with PEXIT token");
} }
const IR::Condition cond{flow_test, static_cast<IR::Pred>(pred.index), pred.negated}; const IR::Condition cond{flow_test, static_cast<IR::Pred>(pred.index), pred.negated};
AnalyzeCondInst(block, function_id, pc, EndClass::Exit, cond); AnalyzeCondInst(block, function_id, pc, EndClass::Exit, cond, false);
return AnalysisState::Branch; return AnalysisState::Branch;
} }
if (const std::optional<Location> exit_pc{block->stack.Peek(Token::PEXIT)}) { if (const std::optional<Location> exit_pc{block->stack.Peek(Token::PEXIT)}) {

View File

@ -128,7 +128,7 @@ private:
AnalysisState AnalyzeInst(Block* block, FunctionId function_id, Location pc); AnalysisState AnalyzeInst(Block* block, FunctionId function_id, Location pc);
void AnalyzeCondInst(Block* block, FunctionId function_id, Location pc, EndClass insn_end_class, void AnalyzeCondInst(Block* block, FunctionId function_id, Location pc, EndClass insn_end_class,
IR::Condition cond); IR::Condition cond, bool visit_conditional_inst);
/// Return true when the branch instruction is confirmed to be a branch /// Return true when the branch instruction is confirmed to be a branch
bool AnalyzeBranch(Block* block, FunctionId function_id, Location pc, Instruction inst, bool AnalyzeBranch(Block* block, FunctionId function_id, Location pc, Instruction inst,