aboutsummaryrefslogtreecommitdiff
path: root/src/shader_recompiler/ir_opt
diff options
context:
space:
mode:
authorlizzie <lizzie@eden-emu.dev>2025-12-31 17:00:29 +0100
committercrueter <crueter@eden-emu.dev>2025-12-31 17:00:29 +0100
commit46b32b76886b5cd0cfc8dfee1a02c3e83fb1e7d7 (patch)
tree281a110374e3cdaf60fec43cc043fb3cccc016a1 /src/shader_recompiler/ir_opt
parent55646657e17a99a9ddd3da4b552f3d9ac233037b (diff)
[vk, ogl/IR, dynarmic/IR] friendlier IR identity pointer chasing, inline AA passes (#2565)
- use std::optional instead of std::unique_ptr for the Antialias (FXAA, etc) passes to avoid the extra deref - use a pattern for deferencing the IR pointer chasing loop as suggested on the intel optimization manual - this also removes std::vector<> overhead by using boost::container::small_vector<> (not a silver bullet but in the case of this function reduces access times) Signed-off-by: lizzie <lizzie@eden-emu.dev> Co-authored-by: Caio Oliveira <caiooliveirafarias0@gmail.com> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2565 Reviewed-by: Maufeat <sahyno1996@gmail.com> Reviewed-by: MaranBr <maranbr@eden-emu.dev> Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
Diffstat (limited to 'src/shader_recompiler/ir_opt')
-rw-r--r--src/shader_recompiler/ir_opt/identity_removal_pass.cpp32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/shader_recompiler/ir_opt/identity_removal_pass.cpp b/src/shader_recompiler/ir_opt/identity_removal_pass.cpp
index 951534bbf2..68f8a9ec44 100644
--- a/src/shader_recompiler/ir_opt/identity_removal_pass.cpp
+++ b/src/shader_recompiler/ir_opt/identity_removal_pass.cpp
@@ -1,7 +1,11 @@
+// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
+// SPDX-License-Identifier: GPL-3.0-or-later
+
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <vector>
+#include <boost/container/small_vector.hpp>
#include "shader_recompiler/frontend/ir/basic_block.h"
#include "shader_recompiler/frontend/ir/value.h"
@@ -10,28 +14,30 @@
namespace Shader::Optimization {
void IdentityRemovalPass(IR::Program& program) {
- std::vector<IR::Inst*> to_invalidate;
+ boost::container::small_vector<IR::Inst*, 16> to_invalidate;
for (IR::Block* const block : program.blocks) {
- for (auto inst = block->begin(); inst != block->end();) {
- const size_t num_args{inst->NumArgs()};
+ for (auto it = block->begin(); it != block->end();) {
+ const size_t num_args{it->NumArgs()};
for (size_t i = 0; i < num_args; ++i) {
- IR::Value arg;
- while ((arg = inst->Arg(i)).IsIdentity()) {
- inst->SetArg(i, arg.Inst()->Arg(0));
+ IR::Value arg = it->Arg(i);
+ if (arg.IsIdentity()) {
+ do { // Pointer chasing (3-derefs)
+ arg = arg.Inst()->Arg(0);
+ } while (arg.IsIdentity());
+ it->SetArg(i, arg);
}
}
- if (inst->GetOpcode() == IR::Opcode::Identity ||
- inst->GetOpcode() == IR::Opcode::Void) {
- to_invalidate.push_back(&*inst);
- inst = block->Instructions().erase(inst);
+
+ if (it->GetOpcode() == IR::Opcode::Identity || it->GetOpcode() == IR::Opcode::Void) {
+ to_invalidate.push_back(&*it);
+ it = block->Instructions().erase(it);
} else {
- ++inst;
+ ++it;
}
}
}
- for (IR::Inst* const inst : to_invalidate) {
+ for (IR::Inst* const inst : to_invalidate)
inst->Invalidate();
- }
}
} // namespace Shader::Optimization