diff options
author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2021-05-18 00:24:09 +0200 |
---|---|---|
committer | ameerj <52414509+ameerj@users.noreply.github.com> | 2021-07-23 03:51:31 +0200 |
commit | fb3ba62b3a47ad645b007d5031ed9f8aaa7cb5c0 (patch) | |
tree | a646ef0f5b2fde47b18f00231157282323c46bf0 /src/shader_recompiler/backend/glasm/reg_alloc.cpp | |
parent | glasm: Remove unintentional comma on vector insert (diff) | |
download | yuzu-fb3ba62b3a47ad645b007d5031ed9f8aaa7cb5c0.tar yuzu-fb3ba62b3a47ad645b007d5031ed9f8aaa7cb5c0.tar.gz yuzu-fb3ba62b3a47ad645b007d5031ed9f8aaa7cb5c0.tar.bz2 yuzu-fb3ba62b3a47ad645b007d5031ed9f8aaa7cb5c0.tar.lz yuzu-fb3ba62b3a47ad645b007d5031ed9f8aaa7cb5c0.tar.xz yuzu-fb3ba62b3a47ad645b007d5031ed9f8aaa7cb5c0.tar.zst yuzu-fb3ba62b3a47ad645b007d5031ed9f8aaa7cb5c0.zip |
Diffstat (limited to 'src/shader_recompiler/backend/glasm/reg_alloc.cpp')
-rw-r--r-- | src/shader_recompiler/backend/glasm/reg_alloc.cpp | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/src/shader_recompiler/backend/glasm/reg_alloc.cpp b/src/shader_recompiler/backend/glasm/reg_alloc.cpp index 0e38f467f..707b22247 100644 --- a/src/shader_recompiler/backend/glasm/reg_alloc.cpp +++ b/src/shader_recompiler/backend/glasm/reg_alloc.cpp @@ -30,9 +30,10 @@ Value RegAlloc::Consume(const IR::Value& value) { } void RegAlloc::Unref(IR::Inst& inst) { - inst.DestructiveRemoveUsage(); - if (!inst.HasUses()) { - Free(inst.Definition<Id>()); + IR::Inst& value_inst{AliasInst(inst)}; + value_inst.DestructiveRemoveUsage(); + if (!value_inst.HasUses()) { + Free(value_inst.Definition<Id>()); } } @@ -99,10 +100,7 @@ Value RegAlloc::PeekInst(IR::Inst& inst) { } Value RegAlloc::ConsumeInst(IR::Inst& inst) { - inst.DestructiveRemoveUsage(); - if (!inst.HasUses()) { - Free(inst.Definition<Id>()); - } + Unref(inst); return PeekInst(inst); } @@ -138,4 +136,31 @@ void RegAlloc::Free(Id id) { } } +/*static*/ bool RegAlloc::IsAliased(const IR::Inst& inst) { + switch (inst.GetOpcode()) { + case IR::Opcode::Identity: + case IR::Opcode::BitCastU16F16: + case IR::Opcode::BitCastU32F32: + case IR::Opcode::BitCastU64F64: + case IR::Opcode::BitCastF16U16: + case IR::Opcode::BitCastF32U32: + case IR::Opcode::BitCastF64U64: + return true; + default: + return false; + } +} + +/*static*/ IR::Inst& RegAlloc::AliasInst(IR::Inst& inst) { + IR::Inst* it{&inst}; + while (IsAliased(*it)) { + const IR::Value arg{it->Arg(0)}; + if (arg.IsImmediate()) { + break; + } + it = arg.InstRecursive(); + } + return *it; +} + } // namespace Shader::Backend::GLASM |