[llvm] [NFC][VPlan] Simplify VPValue::removeUser (PR #74708)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 7 02:00:48 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Shao-Ce SUN (sunshaoce)
<details>
<summary>Changes</summary>
I think we don't need to use lambda, and we can end the loop in advance like this.
---
Full diff: https://github.com/llvm/llvm-project/pull/74708.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Vectorize/VPlanValue.h (+5-9)
``````````diff
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;
``````````
</details>
https://github.com/llvm/llvm-project/pull/74708
More information about the llvm-commits
mailing list