[llvm] [NFC][VPlan] Simplify VPValue::removeUser (PR #74708)

Shao-Ce SUN via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 7 03:17:57 PST 2023


https://github.com/sunshaoce updated https://github.com/llvm/llvm-project/pull/74708

>From ec7b71f4c2a7378c7c6e70f2a919594cba8264c2 Mon Sep 17 00:00:00 2001
From: Shao-Ce SUN <sunshaoce at outlook.com>
Date: Thu, 7 Dec 2023 17:55:20 +0800
Subject: [PATCH] [NFC][VPlan] Simplify removeUser

---
 llvm/lib/Transforms/Vectorize/VPlanValue.h | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/VPlanValue.h b/llvm/lib/Transforms/Vectorize/VPlanValue.h
index ac2883b30dc8c..14634dc31878f 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanValue.h
+++ b/llvm/lib/Transforms/Vectorize/VPlanValue.h
@@ -121,18 +121,14 @@ class VPValue {
 
   /// Remove a single \p User from the list of users.
   void removeUser(VPUser &User) {
-    bool Found = false;
     // The same user can be added multiple times, e.g. because the same VPValue
     // is used twice by the same VPUser. Remove a single one.
-    erase_if(Users, [&User, &Found](VPUser *Other) {
-      if (Found)
-        return false;
-      if (Other == &User) {
-        Found = true;
-        return true;
+    for (const auto &U : Users) {
+      if (U == &User) {
+        Users.erase(&U);
+        return;
       }
-      return false;
-    });
+    }
   }
 
   typedef SmallVectorImpl<VPUser *>::iterator user_iterator;



More information about the llvm-commits mailing list