[Mlir-commits] [mlir] [Bytecode] Avoid repeated hash lookups (NFC) (PR #108320)
Kazu Hirata
llvmlistbot at llvm.org
Wed Sep 11 20:00:24 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/108320
None
>From dae03674fc5d9bcb56e41e6ee296fcf9d4dce9fe Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Wed, 11 Sep 2024 06:49:00 -0700
Subject: [PATCH] [Bytecode] Avoid repeated hash lookups (NFC)
---
mlir/lib/Bytecode/Reader/BytecodeReader.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/mlir/lib/Bytecode/Reader/BytecodeReader.cpp b/mlir/lib/Bytecode/Reader/BytecodeReader.cpp
index a57b2178aec707..e9de3062d41c70 100644
--- a/mlir/lib/Bytecode/Reader/BytecodeReader.cpp
+++ b/mlir/lib/Bytecode/Reader/BytecodeReader.cpp
@@ -2017,10 +2017,9 @@ LogicalResult BytecodeReader::Impl::sortUseListOrder(Value value) {
DenseSet<unsigned> set;
uint64_t accumulator = 0;
for (const auto &elem : shuffle) {
- if (set.contains(elem))
+ if (!set.insert(elem).second)
return failure();
accumulator += elem;
- set.insert(elem);
}
if (numUses != shuffle.size() ||
accumulator != (((numUses - 1) * numUses) >> 1))
More information about the Mlir-commits
mailing list