Skip to content

Commit 5a8e60e

Browse files
authored
[mlir] Use llvm::fill instead of std::fill(NFC) (#146889)
1 parent 718e647 commit 5a8e60e

File tree

11 files changed

+20
-21
lines changed

11 files changed

+20
-21
lines changed

mlir/lib/Analysis/Presburger/IntegerRelation.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2214,7 +2214,7 @@ IntegerRelation::unionBoundingBox(const IntegerRelation &otherCst) {
22142214
auto constOtherLb = otherCst.getConstantBound(BoundType::LB, d);
22152215
if (!constLb.has_value() || !constOtherLb.has_value())
22162216
return failure();
2217-
std::fill(minLb.begin(), minLb.end(), 0);
2217+
llvm::fill(minLb, 0);
22182218
minLb.back() = std::min(*constLb, *constOtherLb);
22192219
}
22202220

@@ -2230,12 +2230,12 @@ IntegerRelation::unionBoundingBox(const IntegerRelation &otherCst) {
22302230
auto constOtherUb = otherCst.getConstantBound(BoundType::UB, d);
22312231
if (!constUb.has_value() || !constOtherUb.has_value())
22322232
return failure();
2233-
std::fill(maxUb.begin(), maxUb.end(), 0);
2233+
llvm::fill(maxUb, 0);
22342234
maxUb.back() = std::max(*constUb, *constOtherUb);
22352235
}
22362236

2237-
std::fill(newLb.begin(), newLb.end(), 0);
2238-
std::fill(newUb.begin(), newUb.end(), 0);
2237+
llvm::fill(newLb, 0);
2238+
llvm::fill(newUb, 0);
22392239

22402240
// The divisor for lb, ub, otherLb, otherUb at this point is lbDivisor,
22412241
// and so it's the divisor for newLb and newUb as well.

mlir/lib/Analysis/Presburger/PWMAFunction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ void MultiAffineFunction::mergeDivs(MultiAffineFunction &other) {
143143
SmallVector<DynamicAPInt, 8> div(other.divs.getNumVars() + 1);
144144
for (unsigned i = 0; i < nDivs; ++i) {
145145
// Zero fill.
146-
std::fill(div.begin(), div.end(), 0);
146+
llvm::fill(div, 0);
147147
// Fill div with dividend from `divs`. Do not fill the constant.
148148
std::copy(divs.getDividend(i).begin(), divs.getDividend(i).end() - 1,
149149
div.begin());

mlir/lib/Bindings/Python/IRAttributes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1670,7 +1670,7 @@ class PyStridedLayoutAttribute
16701670
[](int64_t rank, DefaultingPyMlirContext ctx) {
16711671
auto dynamic = mlirShapedTypeGetDynamicStrideOrOffset();
16721672
std::vector<int64_t> strides(rank);
1673-
std::fill(strides.begin(), strides.end(), dynamic);
1673+
llvm::fill(strides, dynamic);
16741674
MlirAttribute attr = mlirStridedLayoutAttrGet(
16751675
ctx->get(), dynamic, strides.size(), strides.data());
16761676
return PyStridedLayoutAttribute(ctx->getRef(), attr);

mlir/lib/Dialect/Affine/Analysis/AffineAnalysis.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ static void addOrderingConstraints(const FlatAffineValueConstraints &srcDomain,
391391
unsigned numCommonLoops = getNumCommonLoops(srcDomain, dstDomain);
392392
unsigned numCommonLoopConstraints = std::min(numCommonLoops, loopDepth);
393393
for (unsigned i = 0; i < numCommonLoopConstraints; ++i) {
394-
std::fill(eq.begin(), eq.end(), 0);
394+
llvm::fill(eq, 0);
395395
eq[i] = -1;
396396
eq[i + numSrcDims] = 1;
397397
if (i == loopDepth - 1) {
@@ -433,7 +433,7 @@ static void computeDirectionVector(
433433
// Constraint variables format:
434434
// [num-common-loops][num-src-dim-ids][num-dst-dim-ids][num-symbols][constant]
435435
for (unsigned j = 0; j < numCommonLoops; ++j) {
436-
std::fill(eq.begin(), eq.end(), 0);
436+
llvm::fill(eq, 0);
437437
eq[j] = 1;
438438
eq[j + numCommonLoops] = 1;
439439
eq[j + numCommonLoops + numSrcDims] = -1;

mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ LogicalResult mlir::affine::getRelationFromMap(AffineMap &map,
526526
SmallVector<int64_t, 8> eq(localVarCst.getNumCols());
527527
for (unsigned i = 0, e = map.getNumResults(); i < e; ++i) {
528528
// Zero fill.
529-
std::fill(eq.begin(), eq.end(), 0);
529+
llvm::fill(eq, 0);
530530
// Fill equality.
531531
for (unsigned j = 0, f = oldDimNum; j < f; ++j)
532532
eq[j] = flatExprs[i][j];

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1432,7 +1432,7 @@ LogicalResult mlir::affine::boundCheckLoadOrStoreOp(LoadOrStoreOp loadOrStoreOp,
14321432

14331433
// Check for a negative index.
14341434
FlatAffineValueConstraints lcst(*region.getConstraints());
1435-
std::fill(ineq.begin(), ineq.end(), 0);
1435+
llvm::fill(ineq, 0);
14361436
// d_i <= -1;
14371437
lcst.addBound(BoundType::UB, r, -1);
14381438
outOfBounds = !lcst.isEmpty();

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ void LoopTiling::getTileSizes(ArrayRef<AffineForOp> band,
121121
// If the cache size is zero, set the minimum valid tile size. No good reason
122122
// to pick another specific size over this.
123123
if (cacheSizeInKiB == 0) {
124-
std::fill(tileSizes->begin(), tileSizes->end(), 1);
124+
llvm::fill(*tileSizes, 1);
125125
return;
126126
}
127127

@@ -136,8 +136,7 @@ void LoopTiling::getTileSizes(ArrayRef<AffineForOp> band,
136136
std::optional<int64_t> fp = getMemoryFootprintBytes(band[0], 0);
137137
if (!fp) {
138138
// Fill with default tile sizes if footprint is unknown.
139-
std::fill(tileSizes->begin(), tileSizes->end(),
140-
LoopTiling::kDefaultTileSize);
139+
llvm::fill(*tileSizes, LoopTiling::kDefaultTileSize);
141140
if (avoidMaxMinBounds)
142141
adjustToDivisorsOfTripCounts(band, tileSizes);
143142
LLVM_DEBUG(
@@ -151,7 +150,7 @@ void LoopTiling::getTileSizes(ArrayRef<AffineForOp> band,
151150
uint64_t excessFactor = llvm::divideCeil(*fp, cacheSizeBytes);
152151
if (excessFactor <= 1) {
153152
// No need of any tiling - set tile size to 1.
154-
std::fill(tileSizes->begin(), tileSizes->end(), 1);
153+
llvm::fill(*tileSizes, 1);
155154
return;
156155
}
157156

mlir/lib/Dialect/SparseTensor/Transforms/Utils/IterationGraphSorter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,10 @@ IterationGraphSorter::IterationGraphSorter(
167167
AffineMap IterationGraphSorter::sort(SortMask mask, Value ignored) {
168168
// Reset the adjacency matrix that represents the iteration graph.
169169
for (auto &row : itGraph)
170-
std::fill(row.begin(), row.end(), false);
170+
llvm::fill(row, false);
171171

172172
// Reset in-degree.
173-
std::fill(inDegree.begin(), inDegree.end(), 0);
173+
llvm::fill(inDegree, 0);
174174

175175
// Add the constraints for the loop to level map.
176176
for (auto [in, map] : llvm::zip(ins, loop2InsLvl)) {

mlir/lib/IR/AffineExpr.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,7 +1402,7 @@ LogicalResult SimpleAffineExprFlattener::visitModExpr(AffineBinaryOpExpr expr) {
14021402
break;
14031403
// If yes, modulo expression here simplifies to zero.
14041404
if (i == lhs.size()) {
1405-
std::fill(lhs.begin(), lhs.end(), 0);
1405+
llvm::fill(lhs, 0);
14061406
return success();
14071407
}
14081408

@@ -1482,7 +1482,7 @@ LogicalResult SimpleAffineExprFlattener::addLocalVariableSemiAffine(
14821482
if (failed(addLocalIdSemiAffine(lhs, rhs, localExpr)))
14831483
return failure();
14841484
}
1485-
std::fill(result.begin(), result.end(), 0);
1485+
llvm::fill(result, 0);
14861486
if (loc == -1)
14871487
result[getLocalVarStartIndex() + numLocals - 1] = 1;
14881488
else
@@ -1569,7 +1569,7 @@ LogicalResult SimpleAffineExprFlattener::visitDivExpr(AffineBinaryOpExpr expr,
15691569
}
15701570
// Set the expression on stack to the local var introduced to capture the
15711571
// result of the division (floor or ceil).
1572-
std::fill(lhs.begin(), lhs.end(), 0);
1572+
llvm::fill(lhs, 0);
15731573
if (loc == -1)
15741574
lhs[getLocalVarStartIndex() + numLocals - 1] = 1;
15751575
else

mlir/lib/Pass/Pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ void OpToOpPassAdaptor::runOnOperationAsyncImpl(bool verifyPasses) {
829829

830830
// An atomic failure variable for the async executors.
831831
std::vector<std::atomic<bool>> activePMs(asyncExecutors.size());
832-
std::fill(activePMs.begin(), activePMs.end(), false);
832+
llvm::fill(activePMs, false);
833833
std::atomic<bool> hasFailure = false;
834834
parallelForEach(context, opInfos, [&](OpPMInfo &opInfo) {
835835
// Find an executor for this operation.

0 commit comments

Comments
 (0)