[llvm] [NFC][VPlan] Simplify VPValue::removeUser (PR #74708)
Shao-Ce SUN via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 7 23:20:29 PST 2023
https://github.com/sunshaoce updated https://github.com/llvm/llvm-project/pull/74708
>From 8268a3b3f2659a3670f524aab5d812f39f3f8327 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 1/2] [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 ac2883b30dc8ce..14634dc31878fb 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;
>From 16db6199e0a9163c7e6e3439cc99dcdc871fae7a Mon Sep 17 00:00:00 2001
From: Shao-Ce SUN <sunshaoce at outlook.com>
Date: Fri, 8 Dec 2023 15:19:09 +0800
Subject: [PATCH 2/2] address @topperc 's comment
---
llvm/lib/Transforms/Vectorize/VPlanValue.h | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/llvm/lib/Transforms/Vectorize/VPlanValue.h b/llvm/lib/Transforms/Vectorize/VPlanValue.h
index 14634dc31878fb..7ea610b5c032cf 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanValue.h
+++ b/llvm/lib/Transforms/Vectorize/VPlanValue.h
@@ -123,12 +123,9 @@ class VPValue {
void removeUser(VPUser &User) {
// 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.
- for (const auto &U : Users) {
- if (U == &User) {
- Users.erase(&U);
- return;
- }
- }
+ auto *I = llvm::find(Users, &User);
+ if (I != Users.end())
+ Users.erase(I);
}
typedef SmallVectorImpl<VPUser *>::iterator user_iterator;
More information about the llvm-commits
mailing list