[llvm] Revert "[ADT] Make set_subtract more efficient when subtrahend is larger (NFC)" (PR #99386)

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 17 14:01:17 PDT 2024


https://github.com/teresajohnson created https://github.com/llvm/llvm-project/pull/99386

Reverts llvm/llvm-project#98702

This broke some mlir code and needs investigation.

>From 109ff32145687a96e7ef72f9d4f8f3bf45fe2b17 Mon Sep 17 00:00:00 2001
From: Teresa Johnson <tejohnson at google.com>
Date: Wed, 17 Jul 2024 14:00:53 -0700
Subject: [PATCH] =?UTF-8?q?Revert=20"[ADT]=20Make=20set=5Fsubtract=20more?=
 =?UTF-8?q?=20efficient=20when=20subtrahend=20is=20larger=20(NFC=E2=80=A6"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commit fffe2728534a238ff0024e11a18280f85094dcde.
---
 llvm/include/llvm/ADT/SetOperations.h | 15 ---------------
 1 file changed, 15 deletions(-)

diff --git a/llvm/include/llvm/ADT/SetOperations.h b/llvm/include/llvm/ADT/SetOperations.h
index ba784bddfe79a..1a911b239f4c6 100644
--- a/llvm/include/llvm/ADT/SetOperations.h
+++ b/llvm/include/llvm/ADT/SetOperations.h
@@ -94,22 +94,7 @@ S1Ty set_difference(const S1Ty &S1, const S2Ty &S2) {
 
 /// set_subtract(A, B) - Compute A := A - B
 ///
-/// Selects the set to iterate based on the relative sizes of A and B for better
-/// efficiency.
-///
 template <class S1Ty, class S2Ty> void set_subtract(S1Ty &S1, const S2Ty &S2) {
-  using ElemTy = decltype(*S1.begin());
-  // A couple callers pass a vector for S2, which doesn't support contains(),
-  // and wouldn't be efficient if it did.
-  if constexpr (detail::HasMemberContains<S2Ty, ElemTy>) {
-    if (S1.size() < S2.size()) {
-      for (typename S1Ty::iterator SI = S1.begin(), SE = S1.end(); SI != SE;
-           ++SI)
-        if (S2.contains(*SI))
-          S1.erase(SI);
-      return;
-    }
-  }
   for (typename S2Ty::const_iterator SI = S2.begin(), SE = S2.end(); SI != SE;
        ++SI)
     S1.erase(*SI);



More information about the llvm-commits mailing list