[PATCH] D103970: Fix range-loop-analysis warning

Keith Smiley via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 9 09:10:16 PDT 2021


keith created this revision.
keith added a reviewer: sdesmalen.
Herald added a subscriber: hiraditya.
keith requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

  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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103970

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


Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -8021,7 +8021,7 @@
        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);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103970.350917.patch
Type: text/x-patch
Size: 549 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210609/eff15867/attachment.bin>


More information about the llvm-commits mailing list