From e96214ddefb98d18c4448604a746657dba1da91f Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Sat, 13 Nov 2021 20:01:12 +0000 Subject: [PATCH] Fix some clang-tidy reports in MLIR (NFC) Mostly replace uses of `container.size()` with `container.empty()` in conditionals when applicable. --- mlir/lib/Transforms/LoopFusion.cpp | 2 +- mlir/lib/Transforms/NormalizeMemRefs.cpp | 1 - mlir/lib/Transforms/ParallelLoopCollapsing.cpp | 6 +++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/mlir/lib/Transforms/LoopFusion.cpp b/mlir/lib/Transforms/LoopFusion.cpp index 6a456ea..24ef03ba 100644 --- a/mlir/lib/Transforms/LoopFusion.cpp +++ b/mlir/lib/Transforms/LoopFusion.cpp @@ -1565,7 +1565,7 @@ public: // producer scenarios will still go through profitability analysis // if only one of the stores is involved the producer-consumer // relationship of the candidate loops. - assert(producerStores.size() > 0 && "Expected producer store"); + assert(!producerStores.empty() && "Expected producer store"); if (producerStores.size() > 1) LLVM_DEBUG(llvm::dbgs() << "Skipping profitability analysis. Not " "supported for this case\n"); diff --git a/mlir/lib/Transforms/NormalizeMemRefs.cpp b/mlir/lib/Transforms/NormalizeMemRefs.cpp index 4a4deb5..c3fa7fe4 100644 --- a/mlir/lib/Transforms/NormalizeMemRefs.cpp +++ b/mlir/lib/Transforms/NormalizeMemRefs.cpp @@ -460,7 +460,6 @@ void NormalizeMemRefs::normalizeFuncOpMemRefs(FuncOp funcOp, MemRefType newMemRefType = normalizeMemRefType(memrefType, b, /*numSymbolicOperands=*/0); resultTypes.push_back(newMemRefType); - continue; } FunctionType newFuncType = diff --git a/mlir/lib/Transforms/ParallelLoopCollapsing.cpp b/mlir/lib/Transforms/ParallelLoopCollapsing.cpp index 72070a9..2c3329c 100644 --- a/mlir/lib/Transforms/ParallelLoopCollapsing.cpp +++ b/mlir/lib/Transforms/ParallelLoopCollapsing.cpp @@ -28,11 +28,11 @@ struct ParallelLoopCollapsing // The common case for GPU dialect will be simplifying the ParallelOp to 3 // arguments, so we do that here to simplify things. llvm::SmallVector, 3> combinedLoops; - if (clCollapsedIndices0.size()) + if (!clCollapsedIndices0.empty()) combinedLoops.push_back(clCollapsedIndices0); - if (clCollapsedIndices1.size()) + if (!clCollapsedIndices1.empty()) combinedLoops.push_back(clCollapsedIndices1); - if (clCollapsedIndices2.size()) + if (!clCollapsedIndices2.empty()) combinedLoops.push_back(clCollapsedIndices2); collapseParallelLoops(op, combinedLoops); }); -- 2.7.4