shader: Fix Phi node types

This commit is contained in:
ReinUsesLisp 2021-04-17 16:40:35 -03:00 committed by ameerj
parent 0a0818c025
commit 50f8007172
2 changed files with 4 additions and 4 deletions

View File

@ -275,10 +275,6 @@ void Inst::AddPhiOperand(Block* predecessor, const Value& value) {
if (!value.IsImmediate()) { if (!value.IsImmediate()) {
Use(value); Use(value);
} }
if (Flags<IR::Type>() == IR::Type::Void) {
// Set the type of the phi node
SetFlags<IR::Type>(value.Type());
}
phi_args.emplace_back(predecessor, value); phi_args.emplace_back(predecessor, value);
} }

View File

@ -176,6 +176,8 @@ public:
} else if (!sealed_blocks.contains(block)) { } else if (!sealed_blocks.contains(block)) {
// Incomplete CFG // Incomplete CFG
IR::Inst* phi{&*block->PrependNewInst(block->begin(), IR::Opcode::Phi)}; IR::Inst* phi{&*block->PrependNewInst(block->begin(), IR::Opcode::Phi)};
phi->SetFlags(IR::TypeOf(UndefOpcode(variable)));
incomplete_phis[block].insert_or_assign(variable, phi); incomplete_phis[block].insert_or_assign(variable, phi);
stack.back().result = IR::Value{&*phi}; stack.back().result = IR::Value{&*phi};
} else if (const std::span imm_preds{block->ImmediatePredecessors()}; } else if (const std::span imm_preds{block->ImmediatePredecessors()};
@ -187,6 +189,8 @@ public:
} else { } else {
// Break potential cycles with operandless phi // Break potential cycles with operandless phi
IR::Inst* const phi{&*block->PrependNewInst(block->begin(), IR::Opcode::Phi)}; IR::Inst* const phi{&*block->PrependNewInst(block->begin(), IR::Opcode::Phi)};
phi->SetFlags(IR::TypeOf(UndefOpcode(variable)));
WriteVariable(variable, block, IR::Value{phi}); WriteVariable(variable, block, IR::Value{phi});
stack.back().phi = phi; stack.back().phi = phi;