perf(shader): reserve an IR value's arguments for its opcode at creation

Every IR value grew its argument vector one AddArgument at a time from
empty, so a value with three arguments allocated three times (capacity
1, 2 and then 4) and freed the first two. The constructor now reserves
IrOpcodeOperandCount(opcode) arguments, the count IrBuilder::Emit
already requires, so a value built with its opcode's arguments
allocates once. Opcodes without fixed arguments (constants, phis)
reserve nothing, as before. The IR and the SPIR-V are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
milescovielloandClaude Opus 5.5 committed 2026-10-18 11:11:11 +00:00
1 parent 9f25d0bf5b
commit 41b25e4f57
1 file changed
+1
@@ -6,6 +6,7 @@
namespace ShaderRecompiler {
IrValue::IrValue(IrOpcode opcode, IrType type, std::uint32_t id) : opcode(opcode), type(type), id(id), hasImmediate(false), parent(nullptr) {
arguments.reserve(IrOpcodeOperandCount(opcode));
}
std::uint32_t IrValue::Id() const {