shader: Fix instruction transitions in and out of Phi
This commit is contained in:
parent
fa2f6e38f4
commit
8dd0acfaeb
|
@ -182,7 +182,7 @@ void Inst::AddPhiOperand(Block* predecessor, const Value& value) {
|
||||||
|
|
||||||
void Inst::Invalidate() {
|
void Inst::Invalidate() {
|
||||||
ClearArgs();
|
ClearArgs();
|
||||||
op = Opcode::Void;
|
ReplaceOpcode(Opcode::Void);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Inst::ClearArgs() {
|
void Inst::ClearArgs() {
|
||||||
|
@ -206,20 +206,22 @@ void Inst::ClearArgs() {
|
||||||
|
|
||||||
void Inst::ReplaceUsesWith(Value replacement) {
|
void Inst::ReplaceUsesWith(Value replacement) {
|
||||||
Invalidate();
|
Invalidate();
|
||||||
|
ReplaceOpcode(Opcode::Identity);
|
||||||
op = Opcode::Identity;
|
|
||||||
|
|
||||||
if (!replacement.IsImmediate()) {
|
if (!replacement.IsImmediate()) {
|
||||||
Use(replacement);
|
Use(replacement);
|
||||||
}
|
}
|
||||||
if (op == Opcode::Phi) {
|
args[0] = replacement;
|
||||||
phi_args[0].second = replacement;
|
|
||||||
} else {
|
|
||||||
args[0] = replacement;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Inst::ReplaceOpcode(IR::Opcode opcode) {
|
void Inst::ReplaceOpcode(IR::Opcode opcode) {
|
||||||
|
if (opcode == IR::Opcode::Phi) {
|
||||||
|
throw LogicError("Cannot transition into Phi");
|
||||||
|
}
|
||||||
|
if (op == Opcode::Phi) {
|
||||||
|
// Transition out of phi arguments into non-phi
|
||||||
|
std::destroy_at(&phi_args);
|
||||||
|
std::construct_at(&args);
|
||||||
|
}
|
||||||
op = opcode;
|
op = opcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue