[Mlir-commits] [mlir] [Presburger] Avoid repeated hash lookups (NFC) (PR #107426)

Kazu Hirata llvmlistbot at llvm.org
Thu Sep 5 09:45:57 PDT 2024


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/107426

None

>From 117b45f159e0f118d35e3e57c22229423a22cc43 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 5 Sep 2024 08:47:50 -0700
Subject: [PATCH] [Presburger] Avoid repeated hash lookups (NFC)

---
 mlir/lib/Analysis/Presburger/IntegerRelation.cpp | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/mlir/lib/Analysis/Presburger/IntegerRelation.cpp b/mlir/lib/Analysis/Presburger/IntegerRelation.cpp
index 87204d2100713b..94af81f955e5a5 100644
--- a/mlir/lib/Analysis/Presburger/IntegerRelation.cpp
+++ b/mlir/lib/Analysis/Presburger/IntegerRelation.cpp
@@ -2367,10 +2367,8 @@ bool IntegerRelation::removeDuplicateConstraints() {
   hashTable.insert({row, 0});
   for (unsigned k = 1; k < ineqs; ++k) {
     row = getInequality(k).drop_back();
-    if (!hashTable.contains(row)) {
-      hashTable.insert({row, k});
+    if (hashTable.try_emplace(row, k).second)
       continue;
-    }
 
     // For identical cases, keep only the smaller part of the constant term.
     unsigned l = hashTable[row];



More information about the Mlir-commits mailing list