[Mlir-commits] [mlir] 3730658 - [mlir][Linalg] Apply ClangTidy performance finding.

Adrian Kuegel llvmlistbot at llvm.org
Fri Sep 2 01:58:25 PDT 2022


Author: Adrian Kuegel
Date: 2022-09-02T10:57:28+02:00
New Revision: 3730658ed95cd82cc2942f39d55610a5d98f8b23

URL: https://github.com/llvm/llvm-project/commit/3730658ed95cd82cc2942f39d55610a5d98f8b23
DIFF: https://github.com/llvm/llvm-project/commit/3730658ed95cd82cc2942f39d55610a5d98f8b23.diff

LOG: [mlir][Linalg] Apply ClangTidy performance finding.

Loop variable is copied but only used as const reference.

Added: 
    

Modified: 
    mlir/lib/Dialect/Linalg/Utils/Utils.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/Linalg/Utils/Utils.cpp b/mlir/lib/Dialect/Linalg/Utils/Utils.cpp
index 9a170ddbec90..e8fc5ae2f9df 100644
--- a/mlir/lib/Dialect/Linalg/Utils/Utils.cpp
+++ b/mlir/lib/Dialect/Linalg/Utils/Utils.cpp
@@ -502,7 +502,7 @@ void GenerateLoopNest<scf::ForOp>::doit(
     return;
 
   // Filter out scf.for loops that were created out of parallel dimensions.
-  for (auto loop : llvm::enumerate(loopNest.loops)) {
+  for (const auto &loop : llvm::enumerate(loopNest.loops)) {
     if (procInfo[loop.index()].distributionMethod ==
         DistributionMethod::Cyclic) {
       mapLoopToProcessorIds(loop.value(), procInfo[loop.index()].procId,
@@ -704,7 +704,7 @@ void GenerateLoopNest<scf::ParallelOp>::doit(
   unpackRanges(b, loc, loopRanges, lbsStorage, ubsStorage, stepsStorage);
 
   // Modify the lb, ub, and step based on the distribution options.
-  for (auto it : llvm::enumerate(procInfo)) {
+  for (const auto &it : llvm::enumerate(procInfo)) {
     if (it.value().distributionMethod != linalg::DistributionMethod::None) {
       updateBoundsForCyclicDistribution(
           b, loc, it.value().procId, it.value().nprocs, lbsStorage[it.index()],


        


More information about the Mlir-commits mailing list