shader: drop the duplicate-use scan from Inst::AddUse

This commit is contained in:
nmzik committed 2026-10-27 04:23:01 +01:00
1 parent 91a5ff6cb7
commit 7eb8abb279
2 files changed
+6 -5

No files matched your search

@@ -256,9 +256,6 @@ void Inst::Invalidate() {
}
void Inst::AddUse(Inst* used, size_t operand) {
const auto found = std::ranges::find_if(
used->uses, [&](const Use& use) { return use.user == this && use.operand == operand; });
EXIT_IF(found != used->uses.end());
used->uses.push_back({this, operand});
}
+6 -2
View File
@@ -300,8 +300,12 @@ void TestOperandMutationLifecycle() {
auto *source = definition.TryInstruction();
const auto inserted = fixture.Emit(ValueOpcode::BitFieldInsert,
{definition, definition, Value(4u), Value(4u)});
Check(source->UseCount() == 2, "inline operands lost distinct reverse-use indices");
inserted.TryInstruction()->SetArg(1, Value(3u));
auto *consumer = inserted.TryInstruction();
Check(source->Uses() == std::vector<Use>({{consumer, 0}, {consumer, 1}}),
"inline operands lost distinct reverse-use indices");
consumer->SetArg(0, definition);
Check(source->UseCount() == 2, "re-setting an operand to its value duplicated its use");
consumer->SetArg(1, Value(3u));
Check(source->UseCount() == 1, "inline operand mutation did not detach its old use");
source->ReplaceUsesWith(Value(0xaau));
uint32_t result = 0;