Inline common IR operands and share storage with Phi pairs

This commit is contained in:
nmzik
2026-10-02 12:51:36 +04:00
parent 3353c1ff3b
commit 28f29b8e6f
4 changed files with 116 additions and 41 deletions
+12 -3
View File
@@ -4,6 +4,7 @@
#include "graphics/shader/recompiler/ir/Reg.h"
#include "graphics/shader/recompiler/ir/opcodes/ValueOpcodes.h"
#include <array>
#include <bit>
#include <cstdint>
#include <cstring>
@@ -133,7 +134,6 @@ public:
void SetArg(size_t index, Value value);
void AddPhiOperand(Block* predecessor, Value value);
void ReplaceUsesWith(Value replacement, bool preserve = true);
void ReplaceOpcode(ValueOpcode opcode);
void Invalidate();
template <typename T>
@@ -156,13 +156,22 @@ private:
void RemoveUse(Inst* used, size_t operand);
void ClearArgs();
static constexpr uint8_t InlineArity = 4;
static constexpr uint8_t PhiArity = UINT8_MAX;
ValueOpcode opcode;
uint8_t num_args;
mutable uint32_t evaluation_index = UINT32_MAX;
uint64_t flags;
Block* parent = nullptr;
std::vector<Value> args;
std::vector<Block*> phi_blocks;
union {
std::array<Value, InlineArity> fixed_args {};
std::vector<Value> large_args;
std::vector<std::pair<Block*, Value>> phi_args;
};
std::vector<Use> uses;
};
static_assert(sizeof(Inst) <= 112, "Inst operand storage unintentionally increased");
} // namespace Libs::Graphics::ShaderRecompiler::IR