[llvm] 026170d - Fix range-loop-analysis warning

Keith Smiley via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 10 08:49:32 PDT 2021


Author: Keith Smiley
Date: 2021-06-10T08:39:54-07:00
New Revision: 026170d17d1eb8956237ba88c07a60f07445ebf1

URL: https://github.com/llvm/llvm-project/commit/026170d17d1eb8956237ba88c07a60f07445ebf1
DIFF: https://github.com/llvm/llvm-project/commit/026170d17d1eb8956237ba88c07a60f07445ebf1.diff

LOG: Fix range-loop-analysis warning

```
llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:8024:19: warning: loop variable 'VF' of type 'const llvm::ElementCount' creates a copy from type 'const llvm::ElementCount' [-Wrange-loop-analysis]
  for (const auto VF : VFCandidates) {
                  ^
llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:8024:8: note: use reference type 'const llvm::ElementCount &' to prevent copying
  for (const auto VF : VFCandidates) {
       ^~~~~~~~~~~~~~~
                  &
1 warning generated.
```

Differential Revision: https://reviews.llvm.org/D103970

Added: 
    

Modified: 
    llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 82b9642348d0a..bc745c0765d25 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -8021,7 +8021,7 @@ LoopVectorizationPlanner::plan(ElementCount UserVF, unsigned UserIC) {
        ElementCount::isKnownLE(VF, MaxFactors.ScalableVF); VF *= 2)
     VFCandidates.insert(VF);
 
-  for (const auto VF : VFCandidates) {
+  for (const auto &VF : VFCandidates) {
     // Collect Uniform and Scalar instructions after vectorization with VF.
     CM.collectUniformsAndScalars(VF);
 


        


More information about the llvm-commits mailing list