Skip to content

Commit

Permalink
[mlir] Apply ClangTidyPerformance findings (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
akuegel committed Jul 27, 2022
1 parent b1b1086 commit a015421
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
Expand Up @@ -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;
Expand All @@ -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())) {
Expand Down Expand Up @@ -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());
Expand All @@ -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 =
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit a015421

Please sign in to comment.