Skip to content

[mlir] Use llvm::fill instead of std::fill(NFC) #146889

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions mlir/lib/Analysis/Presburger/IntegerRelation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2214,7 +2214,7 @@ IntegerRelation::unionBoundingBox(const IntegerRelation &otherCst) {
auto constOtherLb = otherCst.getConstantBound(BoundType::LB, d);
if (!constLb.has_value() || !constOtherLb.has_value())
return failure();
std::fill(minLb.begin(), minLb.end(), 0);
llvm::fill(minLb, 0);
minLb.back() = std::min(*constLb, *constOtherLb);
}

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

std::fill(newLb.begin(), newLb.end(), 0);
std::fill(newUb.begin(), newUb.end(), 0);
llvm::fill(newLb, 0);
llvm::fill(newUb, 0);

// The divisor for lb, ub, otherLb, otherUb at this point is lbDivisor,
// and so it's the divisor for newLb and newUb as well.
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Analysis/Presburger/PWMAFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void MultiAffineFunction::mergeDivs(MultiAffineFunction &other) {
SmallVector<DynamicAPInt, 8> div(other.divs.getNumVars() + 1);
for (unsigned i = 0; i < nDivs; ++i) {
// Zero fill.
std::fill(div.begin(), div.end(), 0);
llvm::fill(div, 0);
// Fill div with dividend from `divs`. Do not fill the constant.
std::copy(divs.getDividend(i).begin(), divs.getDividend(i).end() - 1,
div.begin());
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Bindings/Python/IRAttributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1670,7 +1670,7 @@ class PyStridedLayoutAttribute
[](int64_t rank, DefaultingPyMlirContext ctx) {
auto dynamic = mlirShapedTypeGetDynamicStrideOrOffset();
std::vector<int64_t> strides(rank);
std::fill(strides.begin(), strides.end(), dynamic);
llvm::fill(strides, dynamic);
MlirAttribute attr = mlirStridedLayoutAttrGet(
ctx->get(), dynamic, strides.size(), strides.data());
return PyStridedLayoutAttribute(ctx->getRef(), attr);
Expand Down
4 changes: 2 additions & 2 deletions mlir/lib/Dialect/Affine/Analysis/AffineAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ static void addOrderingConstraints(const FlatAffineValueConstraints &srcDomain,
unsigned numCommonLoops = getNumCommonLoops(srcDomain, dstDomain);
unsigned numCommonLoopConstraints = std::min(numCommonLoops, loopDepth);
for (unsigned i = 0; i < numCommonLoopConstraints; ++i) {
std::fill(eq.begin(), eq.end(), 0);
llvm::fill(eq, 0);
eq[i] = -1;
eq[i + numSrcDims] = 1;
if (i == loopDepth - 1) {
Expand Down Expand Up @@ -433,7 +433,7 @@ static void computeDirectionVector(
// Constraint variables format:
// [num-common-loops][num-src-dim-ids][num-dst-dim-ids][num-symbols][constant]
for (unsigned j = 0; j < numCommonLoops; ++j) {
std::fill(eq.begin(), eq.end(), 0);
llvm::fill(eq, 0);
eq[j] = 1;
eq[j + numCommonLoops] = 1;
eq[j + numCommonLoops + numSrcDims] = -1;
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ LogicalResult mlir::affine::getRelationFromMap(AffineMap &map,
SmallVector<int64_t, 8> eq(localVarCst.getNumCols());
for (unsigned i = 0, e = map.getNumResults(); i < e; ++i) {
// Zero fill.
std::fill(eq.begin(), eq.end(), 0);
llvm::fill(eq, 0);
// Fill equality.
for (unsigned j = 0, f = oldDimNum; j < f; ++j)
eq[j] = flatExprs[i][j];
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/Affine/Analysis/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1432,7 +1432,7 @@ LogicalResult mlir::affine::boundCheckLoadOrStoreOp(LoadOrStoreOp loadOrStoreOp,

// Check for a negative index.
FlatAffineValueConstraints lcst(*region.getConstraints());
std::fill(ineq.begin(), ineq.end(), 0);
llvm::fill(ineq, 0);
// d_i <= -1;
lcst.addBound(BoundType::UB, r, -1);
outOfBounds = !lcst.isEmpty();
Expand Down
7 changes: 3 additions & 4 deletions mlir/lib/Dialect/Affine/Transforms/LoopTiling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void LoopTiling::getTileSizes(ArrayRef<AffineForOp> band,
// If the cache size is zero, set the minimum valid tile size. No good reason
// to pick another specific size over this.
if (cacheSizeInKiB == 0) {
std::fill(tileSizes->begin(), tileSizes->end(), 1);
llvm::fill(*tileSizes, 1);
return;
}

Expand All @@ -136,8 +136,7 @@ void LoopTiling::getTileSizes(ArrayRef<AffineForOp> band,
std::optional<int64_t> fp = getMemoryFootprintBytes(band[0], 0);
if (!fp) {
// Fill with default tile sizes if footprint is unknown.
std::fill(tileSizes->begin(), tileSizes->end(),
LoopTiling::kDefaultTileSize);
llvm::fill(*tileSizes, LoopTiling::kDefaultTileSize);
if (avoidMaxMinBounds)
adjustToDivisorsOfTripCounts(band, tileSizes);
LLVM_DEBUG(
Expand All @@ -151,7 +150,7 @@ void LoopTiling::getTileSizes(ArrayRef<AffineForOp> band,
uint64_t excessFactor = llvm::divideCeil(*fp, cacheSizeBytes);
if (excessFactor <= 1) {
// No need of any tiling - set tile size to 1.
std::fill(tileSizes->begin(), tileSizes->end(), 1);
llvm::fill(*tileSizes, 1);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ IterationGraphSorter::IterationGraphSorter(
AffineMap IterationGraphSorter::sort(SortMask mask, Value ignored) {
// Reset the adjacency matrix that represents the iteration graph.
for (auto &row : itGraph)
std::fill(row.begin(), row.end(), false);
llvm::fill(row, false);

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

// Add the constraints for the loop to level map.
for (auto [in, map] : llvm::zip(ins, loop2InsLvl)) {
Expand Down
6 changes: 3 additions & 3 deletions mlir/lib/IR/AffineExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1371,7 +1371,7 @@ LogicalResult SimpleAffineExprFlattener::visitModExpr(AffineBinaryOpExpr expr) {
break;
// If yes, modulo expression here simplifies to zero.
if (i == lhs.size()) {
std::fill(lhs.begin(), lhs.end(), 0);
llvm::fill(lhs, 0);
return success();
}

Expand Down Expand Up @@ -1451,7 +1451,7 @@ LogicalResult SimpleAffineExprFlattener::addLocalVariableSemiAffine(
if (failed(addLocalIdSemiAffine(lhs, rhs, localExpr)))
return failure();
}
std::fill(result.begin(), result.end(), 0);
llvm::fill(result, 0);
if (loc == -1)
result[getLocalVarStartIndex() + numLocals - 1] = 1;
else
Expand Down Expand Up @@ -1538,7 +1538,7 @@ LogicalResult SimpleAffineExprFlattener::visitDivExpr(AffineBinaryOpExpr expr,
}
// Set the expression on stack to the local var introduced to capture the
// result of the division (floor or ceil).
std::fill(lhs.begin(), lhs.end(), 0);
llvm::fill(lhs, 0);
if (loc == -1)
lhs[getLocalVarStartIndex() + numLocals - 1] = 1;
else
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Pass/Pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ void OpToOpPassAdaptor::runOnOperationAsyncImpl(bool verifyPasses) {

// An atomic failure variable for the async executors.
std::vector<std::atomic<bool>> activePMs(asyncExecutors.size());
std::fill(activePMs.begin(), activePMs.end(), false);
llvm::fill(activePMs, false);
std::atomic<bool> hasFailure = false;
parallelForEach(context, opInfos, [&](OpPMInfo &opInfo) {
// Find an executor for this operation.
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Transforms/Utils/Inliner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ Inliner::Impl::optimizeSCCAsync(MutableArrayRef<CallGraphNode *> nodesToVisit,

// An atomic failure variable for the async executors.
std::vector<std::atomic<bool>> activePMs(pipelines.size());
std::fill(activePMs.begin(), activePMs.end(), false);
llvm::fill(activePMs, false);
return failableParallelForEach(ctx, nodesToVisit, [&](CallGraphNode *node) {
// Find a pass manager for this operation.
auto it = llvm::find_if(activePMs, [](std::atomic<bool> &isActive) {
Expand Down
Loading