Skip to content

[mlir] Use llvm::append_range (NFC) #135722

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

Merged
Merged
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
6 changes: 2 additions & 4 deletions mlir/include/mlir/Analysis/Presburger/GeneratingFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,10 @@ class GeneratingFunction {
sumSigns.append(gf.signs);

std::vector<ParamPoint> sumNumerators = numerators;
sumNumerators.insert(sumNumerators.end(), gf.numerators.begin(),
gf.numerators.end());
llvm::append_range(sumNumerators, gf.numerators);

std::vector<std::vector<Point>> sumDenominators = denominators;
sumDenominators.insert(sumDenominators.end(), gf.denominators.begin(),
gf.denominators.end());
llvm::append_range(sumDenominators, gf.denominators);
return GeneratingFunction(numParam, sumSigns, sumNumerators,
sumDenominators);
}
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Analysis/Presburger/Barvinok.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ mlir::presburger::detail::computeNumTerms(const GeneratingFunction &gf) {
// d_{ij} and substitute x accordingly.
std::vector<Point> allDenominators;
for (ArrayRef<Point> den : gf.getDenominators())
allDenominators.insert(allDenominators.end(), den.begin(), den.end());
llvm::append_range(allDenominators, den);
Point mu = getNonOrthogonalVector(allDenominators);

unsigned numParams = gf.getNumParams();
Expand Down
6 changes: 3 additions & 3 deletions mlir/lib/Analysis/Presburger/QuasiPolynomial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ QuasiPolynomial QuasiPolynomial::operator+(const QuasiPolynomial &x) const {
SmallVector<Fraction> sumCoeffs = coefficients;
sumCoeffs.append(x.coefficients);
std::vector<std::vector<SmallVector<Fraction>>> sumAff = affine;
sumAff.insert(sumAff.end(), x.affine.begin(), x.affine.end());
llvm::append_range(sumAff, x.affine);
return QuasiPolynomial(getNumInputs(), sumCoeffs, sumAff);
}

Expand Down Expand Up @@ -79,8 +79,8 @@ QuasiPolynomial QuasiPolynomial::operator*(const QuasiPolynomial &x) const {
for (const std::vector<SmallVector<Fraction>> &term : affine) {
for (const std::vector<SmallVector<Fraction>> &xterm : x.affine) {
product.clear();
product.insert(product.end(), term.begin(), term.end());
product.insert(product.end(), xterm.begin(), xterm.end());
llvm::append_range(product, term);
llvm::append_range(product, xterm);
aff.emplace_back(product);
}
}
Expand Down
4 changes: 2 additions & 2 deletions mlir/lib/Analysis/Presburger/Simplex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1507,8 +1507,8 @@ Simplex Simplex::makeProduct(const Simplex &a, const Simplex &b) {
auto concat = [](ArrayRef<Unknown> v, ArrayRef<Unknown> w) {
SmallVector<Unknown, 8> result;
result.reserve(v.size() + w.size());
result.insert(result.end(), v.begin(), v.end());
result.insert(result.end(), w.begin(), w.end());
llvm::append_range(result, v);
llvm::append_range(result, w);
return result;
};
result.con = concat(a.con, b.con);
Expand Down
5 changes: 2 additions & 3 deletions mlir/lib/Bytecode/Writer/BytecodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,9 +568,8 @@ class PropertiesSectionBuilder {
std::vector<char> &newStorage = propertiesStorage.back();
size_t propertiesSize = sizeScratch.size() + rawProperties.size();
newStorage.reserve(propertiesSize);
newStorage.insert(newStorage.end(), sizeScratch.begin(), sizeScratch.end());
newStorage.insert(newStorage.end(), rawProperties.begin(),
rawProperties.end());
llvm::append_range(newStorage, sizeScratch);
llvm::append_range(newStorage, rawProperties);

// Try to de-duplicate the new serialized properties.
// If the properties is a duplicate, pop it back from the storage.
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ static CoroMachinery setupCoroMachinery(func::FuncOp func) {
SmallVector<Value, 4> ret;
if (retToken)
ret.push_back(*retToken);
ret.insert(ret.end(), retValues.begin(), retValues.end());
llvm::append_range(ret, retValues);
builder.create<func::ReturnOp>(ret);

// `async.await` op lowering will create resume blocks for async
Expand Down
14 changes: 4 additions & 10 deletions mlir/lib/Dialect/Linalg/Transforms/DataLayoutPropagation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -676,11 +676,8 @@ bubbleUpPackOpThroughCollapseShape(tensor::CollapseShapeOp collapseOp,
// new permutation after bubbling. This is because moving a collapsed dim is
// equivalent to moving the associated source dims together.
SmallVector<int64_t> newOuterDimsPerm;
for (auto outerPos : outerDimsPerm) {
newOuterDimsPerm.insert(newOuterDimsPerm.end(),
reassocIndices[outerPos].begin(),
reassocIndices[outerPos].end());
}
for (auto outerPos : outerDimsPerm)
llvm::append_range(newOuterDimsPerm, reassocIndices[outerPos]);

auto emptyOp = linalg::PackOp::createDestinationTensor(
rewriter, packOp.getLoc(), collapseOp.getSrc(), packOp.getMixedTiles(),
Expand Down Expand Up @@ -925,11 +922,8 @@ static LogicalResult pushDownUnPackOpThroughExpandShape(
// new permutation after pushing. This is because moving a source dim is
// equivalent to moving the associated expanded dims together.
SmallVector<int64_t> newOuterDimsPerm;
for (auto outerPos : outerDimsPerm) {
newOuterDimsPerm.insert(newOuterDimsPerm.end(),
reassocIndices[outerPos].begin(),
reassocIndices[outerPos].end());
}
for (auto outerPos : outerDimsPerm)
llvm::append_range(newOuterDimsPerm, reassocIndices[outerPos]);

SmallVector<ReassociationIndices> newReassocIndices = reassocIndices;
// First apply the permutation on the reassociations of the outer dims.
Expand Down
4 changes: 2 additions & 2 deletions mlir/lib/Dialect/MemRef/Utils/MemRefUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ static bool resultIsNotRead(Operation *op, std::vector<Operation *> &uses) {
}
return false;
}
uses.insert(uses.end(), opUses.begin(), opUses.end());
llvm::append_range(uses, opUses);
return true;
}

Expand All @@ -150,7 +150,7 @@ void eraseDeadAllocAndStores(RewriterBase &rewriter, Operation *parentOp) {
parentOp->walk([&](memref::AllocOp op) {
std::vector<Operation *> candidates;
if (resultIsNotRead(op, candidates)) {
opToErase.insert(opToErase.end(), candidates.begin(), candidates.end());
llvm::append_range(opToErase, candidates);
opToErase.push_back(op.getOperation());
}
});
Expand Down
3 changes: 1 addition & 2 deletions mlir/lib/Dialect/SCF/IR/SCF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2017,8 +2017,7 @@ IfOp::inferReturnTypes(MLIRContext *ctx, std::optional<Location> loc,
if (!yieldOp)
return failure();
TypeRange types = yieldOp.getOperandTypes();
inferredReturnTypes.insert(inferredReturnTypes.end(), types.begin(),
types.end());
llvm::append_range(inferredReturnTypes, types);
return success();
}

Expand Down
3 changes: 1 addition & 2 deletions mlir/lib/Dialect/Tosa/Transforms/TosaProfileCompliance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,7 @@ SmallVector<StringRef> TosaProfileCompliance::stringifyProfile(

for (const auto &profiles : profileSet) {
auto tempStrings = stringifyProfile<T>(profiles);
debugStrings.insert(debugStrings.end(), tempStrings.begin(),
tempStrings.end());
llvm::append_range(debugStrings, tempStrings);
}

return debugStrings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,7 @@ createFullPartialLinalgCopy(RewriterBase &b, vector::TransferReadOp xferOp,
[&](OpBuilder &b, Location loc) {
Value res = castToCompatibleMemRefType(b, memref, compatibleMemRefType);
scf::ValueVector viewAndIndices{res};
viewAndIndices.insert(viewAndIndices.end(), xferOp.getIndices().begin(),
xferOp.getIndices().end());
llvm::append_range(viewAndIndices, xferOp.getIndices());
b.create<scf::YieldOp>(loc, viewAndIndices);
},
[&](OpBuilder &b, Location loc) {
Expand Down Expand Up @@ -312,8 +311,7 @@ static scf::IfOp createFullPartialVectorTransferRead(
[&](OpBuilder &b, Location loc) {
Value res = castToCompatibleMemRefType(b, memref, compatibleMemRefType);
scf::ValueVector viewAndIndices{res};
viewAndIndices.insert(viewAndIndices.end(), xferOp.getIndices().begin(),
xferOp.getIndices().end());
llvm::append_range(viewAndIndices, xferOp.getIndices());
b.create<scf::YieldOp>(loc, viewAndIndices);
},
[&](OpBuilder &b, Location loc) {
Expand Down Expand Up @@ -362,9 +360,7 @@ getLocationToWriteFullVec(RewriterBase &b, vector::TransferWriteOp xferOp,
Value res =
castToCompatibleMemRefType(b, memref, compatibleMemRefType);
scf::ValueVector viewAndIndices{res};
viewAndIndices.insert(viewAndIndices.end(),
xferOp.getIndices().begin(),
xferOp.getIndices().end());
llvm::append_range(viewAndIndices, xferOp.getIndices());
b.create<scf::YieldOp>(loc, viewAndIndices);
},
[&](OpBuilder &b, Location loc) {
Expand Down
6 changes: 2 additions & 4 deletions mlir/lib/Query/Query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,10 @@ static Operation *extractFunction(std::vector<Operation *> &ops,
slice.push_back(op);

// All results are returned by the extracted function.
outputTypes.insert(outputTypes.end(), op->getResults().getTypes().begin(),
op->getResults().getTypes().end());
llvm::append_range(outputTypes, op->getResults().getTypes());

// Track all values that need to be taken as input to function.
values.insert(values.end(), op->getOperands().begin(),
op->getOperands().end());
llvm::append_range(values, op->getOperands());
}

// Create the function
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ PDLDocument::PDLDocument(const lsp::URIForFile &uri, StringRef contents,
llvm::SmallString<32> uriDirectory(uri.file());
llvm::sys::path::remove_filename(uriDirectory);
includeDirs.push_back(uriDirectory.str().str());
includeDirs.insert(includeDirs.end(), extraDirs.begin(), extraDirs.end());
llvm::append_range(includeDirs, extraDirs);

sourceMgr.setIncludeDirs(includeDirs);
sourceMgr.AddNewSourceBuffer(std::move(memBuffer), SMLoc());
Expand Down
3 changes: 1 addition & 2 deletions mlir/lib/Tools/tblgen-lsp-server/TableGenServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,7 @@ TableGenTextFile::TableGenTextFile(
llvm::SmallString<32> uriDirectory(uri.file());
llvm::sys::path::remove_filename(uriDirectory);
includeDirs.push_back(uriDirectory.str().str());
includeDirs.insert(includeDirs.end(), extraIncludeDirs.begin(),
extraIncludeDirs.end());
llvm::append_range(includeDirs, extraIncludeDirs);

// Initialize the file.
initialize(uri, version, diagnostics);
Expand Down
Loading