Skip to content

Commit d1ceb74

Browse files
authored
[MLIR][Affine] NFC. Fix stale comments and style in affine libraries (#71660)
Fix stale comments in affine libraries; fix clang-tidy warnings/style. NFC.
1 parent 0adbde6 commit d1ceb74

File tree

8 files changed

+8
-33
lines changed

8 files changed

+8
-33
lines changed

mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ struct AffineDataCopyGeneration
8787
/// Generates copies for memref's living in 'slowMemorySpace' into newly created
8888
/// buffers in 'fastMemorySpace', and replaces memory operations to the former
8989
/// by the latter. Only load op's handled for now.
90-
/// TODO: extend this to store op's.
9190
std::unique_ptr<OperationPass<func::FuncOp>>
9291
mlir::affine::createAffineDataCopyGenerationPass(
9392
unsigned slowMemorySpace, unsigned fastMemorySpace, unsigned tagMemorySpace,
@@ -103,7 +102,7 @@ mlir::affine::createAffineDataCopyGenerationPass() {
103102

104103
/// Generate copies for this block. The block is partitioned into separate
105104
/// ranges: each range is either a sequence of one or more operations starting
106-
/// and ending with an affine load or store op, or just an affine.forop (which
105+
/// and ending with an affine load or store op, or just an affine.for op (which
107106
/// could have other affine for op's nested within).
108107
void AffineDataCopyGeneration::runOnBlock(Block *block,
109108
DenseSet<Operation *> &copyNests) {
@@ -125,9 +124,6 @@ void AffineDataCopyGeneration::runOnBlock(Block *block,
125124
// operations excluding AffineForOp's) are always assumed to not exhaust
126125
// memory. As a result, this approach is conservative in some cases at the
127126
// moment; we do a check later and report an error with location info.
128-
// TODO: An 'affine.if' operation is being treated similar to an
129-
// operation. 'affine.if''s could have 'affine.for's in them;
130-
// treat them separately.
131127

132128
// Get to the first load, store, or for op (that is not a copy nest itself).
133129
auto curBegin =

mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ using namespace mlir::affine;
4848

4949
namespace {
5050

51-
/// Loop invariant code motion (LICM) pass.
51+
/// Affine loop invariant code motion (LICM) pass.
5252
/// TODO: The pass is missing zero-trip tests.
5353
/// TODO: This code should be removed once the new LICM pass can handle its
5454
/// uses.

mlir/lib/Dialect/Affine/Transforms/AffineScalarReplacement.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
// This file implements a pass to forward affine memref stores to loads, thereby
1010
// potentially getting rid of intermediate memrefs entirely. It also removes
1111
// redundant loads.
12-
// TODO: In the future, similar techniques could be used to eliminate
13-
// dead memref store's and perform more complex forwarding when support for
14-
// SSA scalars live out of 'affine.for'/'affine.if' statements is available.
1512
//===----------------------------------------------------------------------===//
1613

1714
#include "mlir/Dialect/Affine/Passes.h"

mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,8 @@ namespace {
5151
/// Loop fusion pass. This pass currently supports a greedy fusion policy,
5252
/// which fuses loop nests with single-writer/single-reader memref dependences
5353
/// with the goal of improving locality.
54-
5554
// TODO: Support fusion of source loop nests which write to multiple
5655
// memrefs, where each memref can have multiple users (if profitable).
57-
// TODO: Extend this pass to check for fusion preventing dependences,
58-
// and add support for more general loop fusion algorithms.
59-
6056
struct LoopFusion : public affine::impl::AffineLoopFusionBase<LoopFusion> {
6157
LoopFusion() = default;
6258
LoopFusion(unsigned fastMemorySpace, uint64_t localBufSizeThresholdBytes,

mlir/lib/Dialect/Affine/Transforms/LoopTiling.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ static bool checkTilingLegality(MutableArrayRef<AffineForOp> origLoops) {
138138
<< Twine(d) << " between:\n";);
139139
LLVM_DEBUG(srcAccess.opInst->dump(););
140140
LLVM_DEBUG(dstAccess.opInst->dump(););
141-
for (unsigned k = 0, e = depComps.size(); k < e; k++) {
142-
DependenceComponent depComp = depComps[k];
141+
for (const DependenceComponent &depComp : depComps) {
143142
if (depComp.lb.has_value() && depComp.ub.has_value() &&
144143
*depComp.lb < *depComp.ub && *depComp.ub < 0) {
145144
LLVM_DEBUG(llvm::dbgs()

mlir/lib/Dialect/Affine/Transforms/PipelineDataTransfer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ mlir::affine::createPipelineDataTransferPass() {
5959

6060
// Returns the position of the tag memref operand given a DMA operation.
6161
// Temporary utility: will be replaced when DmaStart/DmaFinish abstract op's are
62-
// added. TODO
62+
// added.
6363
static unsigned getTagMemRefPos(Operation &dmaOp) {
6464
assert((isa<AffineDmaStartOp, AffineDmaWaitOp>(dmaOp)));
6565
if (auto dmaStartOp = dyn_cast<AffineDmaStartOp>(dmaOp)) {

mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ static void replaceIterArgsAndYieldResults(AffineForOp forOp) {
128128

129129
/// Promotes the loop body of a forOp to its containing block if the forOp
130130
/// was known to have a single iteration.
131-
// TODO: extend this for arbitrary affine bounds.
132131
LogicalResult mlir::affine::promoteIfSingleIteration(AffineForOp forOp) {
133132
std::optional<uint64_t> tripCount = getConstantTripCount(forOp);
134133
if (!tripCount || *tripCount != 1)
135134
return failure();
136135

136+
// TODO: extend this for arbitrary affine bounds.
137137
if (forOp.getLowerBoundMap().getNumResults() != 1)
138138
return failure();
139139

@@ -404,6 +404,7 @@ static LogicalResult performPreTilingChecks(MutableArrayRef<AffineForOp> input,
404404
return failure();
405405
}
406406

407+
// TODO: handle non hyper-rectangular spaces.
407408
if (failed(checkIfHyperRectangular(input)))
408409
return failure();
409410

@@ -818,7 +819,6 @@ mlir::affine::tilePerfectlyNested(MutableArrayRef<AffineForOp> input,
818819
/// Tiles the specified band of perfectly nested loops creating tile-space
819820
/// loops and intra-tile loops, using SSA values as tiling parameters. A band
820821
/// is a contiguous set of loops.
821-
// TODO: handle non hyper-rectangular spaces.
822822
LogicalResult mlir::affine::tilePerfectlyNestedParametric(
823823
MutableArrayRef<AffineForOp> input, ArrayRef<Value> tileSizes,
824824
SmallVectorImpl<AffineForOp> *tiledNest) {
@@ -1514,11 +1514,7 @@ AffineForOp mlir::affine::sinkSequentialLoops(AffineForOp forOp) {
15141514
}
15151515
}
15161516

1517-
// Count the number of parallel loops.
1518-
unsigned numParallelLoops = 0;
1519-
for (unsigned i = 0, e = isParallelLoop.size(); i < e; ++i)
1520-
if (isParallelLoop[i])
1521-
++numParallelLoops;
1517+
unsigned numParallelLoops = llvm::count(isParallelLoop, true);
15221518

15231519
// Compute permutation of loops that sinks sequential loops (and thus raises
15241520
// parallel loops) while preserving relative order.
@@ -2559,10 +2555,6 @@ void mlir::affine::gatherLoops(
25592555
}
25602556
}
25612557

2562-
// TODO: if necessary, this can be extended to also compose in any
2563-
// affine.applys, fold to constant if all result dimensions of the map are
2564-
// constant (canonicalizeMapAndOperands below already does this for single
2565-
// result bound maps), and use simplifyMap to perform algebraic simplification.
25662558
AffineForOp mlir::affine::createCanonicalizedAffineForOp(
25672559
OpBuilder b, Location loc, ValueRange lbOperands, AffineMap lbMap,
25682560
ValueRange ubOperands, AffineMap ubMap, int64_t step) {

mlir/lib/IR/AffineMap.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -901,12 +901,7 @@ void MutableAffineMap::reset(AffineMap map) {
901901
}
902902

903903
bool MutableAffineMap::isMultipleOf(unsigned idx, int64_t factor) const {
904-
if (results[idx].isMultipleOf(factor))
905-
return true;
906-
907-
// TODO: use simplifyAffineExpr and FlatAffineValueConstraints to
908-
// complete this (for a more powerful analysis).
909-
return false;
904+
return results[idx].isMultipleOf(factor);
910905
}
911906

912907
// Simplifies the result affine expressions of this map. The expressions

0 commit comments

Comments
 (0)