From 41b25e4f5700a60eeea566775299fddb70e2cebc Mon Sep 17 00:00:00 2001 From: milescoviello Date: Sun, 18 Oct 2026 11:11:11 +0000 Subject: [PATCH] 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 --- .../shader/recompiler/IntermediateRepresentation/src/IrValue.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/core/shader/recompiler/IntermediateRepresentation/src/IrValue.cpp b/core/shader/recompiler/IntermediateRepresentation/src/IrValue.cpp index f5653e80f9..3a2a7c9c41 100644 --- a/core/shader/recompiler/IntermediateRepresentation/src/IrValue.cpp +++ b/core/shader/recompiler/IntermediateRepresentation/src/IrValue.cpp @@ -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 {