[llvm] [NFC][VPlan] Simplify VPValue::removeUser (PR #74708)
Shao-Ce SUN via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 7 02:00:19 PST 2023
https://github.com/sunshaoce created https://github.com/llvm/llvm-project/pull/74708
I think we don't need to use lambda, and we can end the loop in advance like this.
>From 3664b2c5131ec482b71b420e909b25057ee54794 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