Skip to content

[LV][NFC] Improve readability with bool instead of auto #111532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 10, 2024

Conversation

pfusik
Copy link
Contributor

@pfusik pfusik commented Oct 8, 2024

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Oct 8, 2024

@llvm/pr-subscribers-llvm-transforms

Author: Piotr Fusik (pfusik)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/111532.diff

1 Files Affected:

  • (modified) llvm/lib/Transforms/Vectorize/LoopVectorize.cpp (+5-5)
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 001c8987667df8..dc0a9fc68cdc4b 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -3204,7 +3204,7 @@ void LoopVectorizationCostModel::collectLoopScalars(ElementCount VF) {
 
     // Determine if all users of the induction variable are scalar after
     // vectorization.
-    auto ScalarInd = llvm::all_of(Ind->users(), [&](User *U) -> bool {
+    bool ScalarInd = llvm::all_of(Ind->users(), [&](User *U) -> bool {
       auto *I = cast<Instruction>(U);
       return I == IndUpdate || !TheLoop->contains(I) || Worklist.count(I) ||
              IsDirectLoadStoreFromPtrIndvar(Ind, I);
@@ -3221,7 +3221,7 @@ void LoopVectorizationCostModel::collectLoopScalars(ElementCount VF) {
 
     // Determine if all users of the induction variable update instruction are
     // scalar after vectorization.
-    auto ScalarIndUpdate =
+    bool ScalarIndUpdate =
         llvm::all_of(IndUpdate->users(), [&](User *U) -> bool {
           auto *I = cast<Instruction>(U);
           return I == Ind || !TheLoop->contains(I) || Worklist.count(I) ||
@@ -3649,7 +3649,7 @@ void LoopVectorizationCostModel::collectLoopUniforms(ElementCount VF) {
     if (IsOutOfScope(V))
       continue;
     auto *I = cast<Instruction>(V);
-    auto UsersAreMemAccesses =
+    bool UsersAreMemAccesses =
       llvm::all_of(I->users(), [&](User *U) -> bool {
         auto *UI = cast<Instruction>(U);
         return TheLoop->contains(UI) && IsVectorizedMemAccessUse(UI, V);
@@ -3698,7 +3698,7 @@ void LoopVectorizationCostModel::collectLoopUniforms(ElementCount VF) {
 
     // Determine if all users of the induction variable are uniform after
     // vectorization.
-    auto UniformInd = llvm::all_of(Ind->users(), [&](User *U) -> bool {
+    bool UniformInd = llvm::all_of(Ind->users(), [&](User *U) -> bool {
       auto *I = cast<Instruction>(U);
       return I == IndUpdate || !TheLoop->contains(I) || Worklist.count(I) ||
              IsVectorizedMemAccessUse(I, Ind);
@@ -3708,7 +3708,7 @@ void LoopVectorizationCostModel::collectLoopUniforms(ElementCount VF) {
 
     // Determine if all users of the induction variable update instruction are
     // uniform after vectorization.
-    auto UniformIndUpdate =
+    bool UniformIndUpdate =
         llvm::all_of(IndUpdate->users(), [&](User *U) -> bool {
           auto *I = cast<Instruction>(U);
           return I == Ind || !TheLoop->contains(I) || Worklist.count(I) ||

Copy link

github-actions bot commented Oct 8, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@@ -3204,7 +3204,7 @@ void LoopVectorizationCostModel::collectLoopScalars(ElementCount VF) {

// Determine if all users of the induction variable are scalar after
// vectorization.
auto ScalarInd = llvm::all_of(Ind->users(), [&](User *U) -> bool {
bool ScalarInd = llvm::all_of(Ind->users(), [&](User *U) -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while you are editing the line, might as well drop redundant llvm::

Suggested change
bool ScalarInd = llvm::all_of(Ind->users(), [&](User *U) -> bool {
bool ScalarInd = llvm::all_of(Ind->users(), [&](User *U) -> bool {

auto *UI = cast<Instruction>(U);
return TheLoop->contains(UI) && IsVectorizedMemAccessUse(UI, V);
});
bool UsersAreMemAccesses = llvm::all_of(I->users(), [&](User *U) -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while you are editing the line, might as well drop redundant llvm::

Suggested change
bool UsersAreMemAccesses = llvm::all_of(I->users(), [&](User *U) -> bool {
bool UsersAreMemAccesses = all_of(I->users(), [&](User *U) -> bool {

@@ -3698,7 +3697,7 @@ void LoopVectorizationCostModel::collectLoopUniforms(ElementCount VF) {

// Determine if all users of the induction variable are uniform after
// vectorization.
auto UniformInd = llvm::all_of(Ind->users(), [&](User *U) -> bool {
bool UniformInd = llvm::all_of(Ind->users(), [&](User *U) -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while you are editing the line, might as well drop redundant llvm::

Suggested change
bool UniformInd = llvm::all_of(Ind->users(), [&](User *U) -> bool {
bool UniformInd = all_of(Ind->users(), [&](User *U) -> bool {

@@ -3221,7 +3221,7 @@ void LoopVectorizationCostModel::collectLoopScalars(ElementCount VF) {

// Determine if all users of the induction variable update instruction are
// scalar after vectorization.
auto ScalarIndUpdate =
bool ScalarIndUpdate =
llvm::all_of(IndUpdate->users(), [&](User *U) -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while you are editing around here, might as well drop redundant llvm::

Suggested change
llvm::all_of(IndUpdate->users(), [&](User *U) -> bool {
all_of(IndUpdate->users(), [&](User *U) -> bool {

@@ -3708,7 +3707,7 @@ void LoopVectorizationCostModel::collectLoopUniforms(ElementCount VF) {

// Determine if all users of the induction variable update instruction are
// uniform after vectorization.
auto UniformIndUpdate =
bool UniformIndUpdate =
llvm::all_of(IndUpdate->users(), [&](User *U) -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while you are editing around here, might as well drop redundant llvm::

Suggested change
llvm::all_of(IndUpdate->users(), [&](User *U) -> bool {
all_of(IndUpdate->users(), [&](User *U) -> bool {

Copy link
Contributor

@fhahn fhahn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@pfusik pfusik merged commit a7a4daa into llvm:main Oct 10, 2024
8 checks passed
DanielCChen pushed a commit to DanielCChen/llvm-project that referenced this pull request Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants