[Mlir-commits] [mlir] a015421 - [mlir] Apply ClangTidyPerformance findings (NFC)

Adrian Kuegel llvmlistbot at llvm.org
Wed Jul 27 01:05:48 PDT 2022


Author: Adrian Kuegel
Date: 2022-07-27T10:05:22+02:00
New Revision: a0154218c33d1016f297cb2dd75c270b0c8a3ba3

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

LOG: [mlir] Apply ClangTidyPerformance findings (NFC)

Added: 
    

Modified: 
    mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
index 4faddf0fa5af8..8669165fe76f5 100644
--- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
+++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
@@ -908,7 +908,7 @@ struct DeduplicateAndRemoveDeadOperandsAndResults
 
     // Replace all live uses of the op.
     SmallVector<Value> replacementsVals(genericOp->getNumResults(), nullptr);
-    for (auto result : llvm::enumerate(genericOp.getResults())) {
+    for (const auto &result : llvm::enumerate(genericOp.getResults())) {
       auto it = origOutsToNewOutsPos.find(result.index());
       if (it == origOutsToNewOutsPos.end())
         continue;
@@ -930,7 +930,8 @@ struct DeduplicateAndRemoveDeadOperandsAndResults
                            SmallVector<AffineMap> &newIndexingMaps) const {
     llvm::SmallDenseMap<unsigned, unsigned> origToNewPos;
     llvm::SmallDenseMap<std::pair<Value, AffineMap>, unsigned> dedupedInputs;
-    for (auto inputOpOperand : llvm::enumerate(genericOp.getInputOperands())) {
+    for (const auto &inputOpOperand :
+         llvm::enumerate(genericOp.getInputOperands())) {
       // Check if operand is dead and if dropping the indexing map makes the
       // loops to shape computation invalid.
       if (!genericOp.payloadUsesValueFromOperand(inputOpOperand.value())) {
@@ -978,7 +979,7 @@ struct DeduplicateAndRemoveDeadOperandsAndResults
     // If the op doesnt have tensor semantics, keep all the outputs as
     // preserved.
     if (!genericOp.hasTensorSemantics()) {
-      for (auto outputOpOperand :
+      for (const auto &outputOpOperand :
            llvm::enumerate(genericOp.getOutputOperands())) {
         origToNewPos[outputOpOperand.index()] = newOutputOperands.size();
         newOutputOperands.push_back(outputOpOperand.value()->get());
@@ -992,7 +993,7 @@ struct DeduplicateAndRemoveDeadOperandsAndResults
       // - the corresponding indexing maps are not needed for loop bound
       //   computation.
       auto yieldOp = cast<YieldOp>(genericOp.getBody()->getTerminator());
-      for (auto outputOpOperand :
+      for (const auto &outputOpOperand :
            llvm::enumerate(genericOp.getOutputOperands())) {
         Value result = genericOp.getResult(outputOpOperand.index());
         AffineMap indexingMap =
@@ -1056,7 +1057,7 @@ struct DeduplicateAndRemoveDeadOperandsAndResults
     auto updateReplacements =
         [&](OpOperandVector &origOperands, OpOperandVector &newOperands,
             const llvm::SmallDenseMap<unsigned, unsigned> &map) {
-          for (auto origOperand : llvm::enumerate(origOperands)) {
+          for (const auto &origOperand : llvm::enumerate(origOperands)) {
             auto it = map.find(origOperand.index());
             if (it == map.end())
               continue;


        


More information about the Mlir-commits mailing list