diff options
| author | 2021-03-17 01:30:23 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:23 -0400 | |
| commit | 8dd0acfaeba9396fb5c1e142a431a2a29f345855 (patch) | |
| tree | de90d9ab871c892008267b33493d1d8c0e9e17d5 /src/shader_recompiler/frontend | |
| parent | shader: Implement FSET and FSETP (diff) | |
| download | yuzu-8dd0acfaeba9396fb5c1e142a431a2a29f345855.tar.gz yuzu-8dd0acfaeba9396fb5c1e142a431a2a29f345855.tar.xz yuzu-8dd0acfaeba9396fb5c1e142a431a2a29f345855.zip | |
shader: Fix instruction transitions in and out of Phi
Diffstat (limited to 'src/shader_recompiler/frontend')
| -rw-r--r-- | src/shader_recompiler/frontend/ir/microinstruction.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/shader_recompiler/frontend/ir/microinstruction.cpp b/src/shader_recompiler/frontend/ir/microinstruction.cpp index 88e186f21..5946105d2 100644 --- a/src/shader_recompiler/frontend/ir/microinstruction.cpp +++ b/src/shader_recompiler/frontend/ir/microinstruction.cpp | |||
| @@ -182,7 +182,7 @@ void Inst::AddPhiOperand(Block* predecessor, const Value& value) { | |||
| 182 | 182 | ||
| 183 | void Inst::Invalidate() { | 183 | void Inst::Invalidate() { |
| 184 | ClearArgs(); | 184 | ClearArgs(); |
| 185 | op = Opcode::Void; | 185 | ReplaceOpcode(Opcode::Void); |
| 186 | } | 186 | } |
| 187 | 187 | ||
| 188 | void Inst::ClearArgs() { | 188 | void Inst::ClearArgs() { |
| @@ -206,20 +206,22 @@ void Inst::ClearArgs() { | |||
| 206 | 206 | ||
| 207 | void Inst::ReplaceUsesWith(Value replacement) { | 207 | void Inst::ReplaceUsesWith(Value replacement) { |
| 208 | Invalidate(); | 208 | Invalidate(); |
| 209 | 209 | ReplaceOpcode(Opcode::Identity); | |
| 210 | op = Opcode::Identity; | ||
| 211 | |||
| 212 | if (!replacement.IsImmediate()) { | 210 | if (!replacement.IsImmediate()) { |
| 213 | Use(replacement); | 211 | Use(replacement); |
| 214 | } | 212 | } |
| 215 | if (op == Opcode::Phi) { | 213 | args[0] = replacement; |
| 216 | phi_args[0].second = replacement; | ||
| 217 | } else { | ||
| 218 | args[0] = replacement; | ||
| 219 | } | ||
| 220 | } | 214 | } |
| 221 | 215 | ||
| 222 | void Inst::ReplaceOpcode(IR::Opcode opcode) { | 216 | void Inst::ReplaceOpcode(IR::Opcode opcode) { |
| 217 | if (opcode == IR::Opcode::Phi) { | ||
| 218 | throw LogicError("Cannot transition into Phi"); | ||
| 219 | } | ||
| 220 | if (op == Opcode::Phi) { | ||
| 221 | // Transition out of phi arguments into non-phi | ||
| 222 | std::destroy_at(&phi_args); | ||
| 223 | std::construct_at(&args); | ||
| 224 | } | ||
| 223 | op = opcode; | 225 | op = opcode; |
| 224 | } | 226 | } |
| 225 | 227 | ||