[Mlir-commits] [mlir] [mlir] Use llvm::transform (NFC) (PR #167205)
Kazu Hirata
llvmlistbot at llvm.org
Sat Nov 8 23:56:05 PST 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/167205
Identified with llvm-use-ranges.
>From 685ba5f8584c1a241678ab4e2b91f231b203885a Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 8 Nov 2025 23:20:27 -0800
Subject: [PATCH] [mlir] Use llvm::transform (NFC)
Identified with llvm-use-ranges.
---
.../mlir/Dialect/Shard/Transforms/Simplifications.h | 6 ++----
mlir/lib/Analysis/FlatLinearValueConstraints.cpp | 4 ++--
mlir/lib/Analysis/Presburger/Utils.cpp | 13 +++++--------
.../Dialect/Affine/Analysis/AffineStructures.cpp | 3 +--
mlir/lib/Dialect/Tosa/IR/TosaOps.cpp | 2 +-
mlir/lib/IR/PatternMatch.cpp | 7 +++----
6 files changed, 14 insertions(+), 21 deletions(-)
diff --git a/mlir/include/mlir/Dialect/Shard/Transforms/Simplifications.h b/mlir/include/mlir/Dialect/Shard/Transforms/Simplifications.h
index 452d4f6b4ed61..d996db88fcb2a 100644
--- a/mlir/include/mlir/Dialect/Shard/Transforms/Simplifications.h
+++ b/mlir/include/mlir/Dialect/Shard/Transforms/Simplifications.h
@@ -50,10 +50,8 @@ void populateAllReduceEndomorphismSimplificationPatterns(
auto getAlgebraicOpOperands = [](Operation *op,
SmallVector<OpOperand *> &operands) {
auto algebraicOp = llvm::cast<AlgebraicOp>(op);
- std::transform(algebraicOp->getOpOperands().begin(),
- algebraicOp->getOpOperands().end(),
- std::back_inserter(operands),
- [](OpOperand &operand) { return &operand; });
+ llvm::transform(algebraicOp->getOpOperands(), std::back_inserter(operands),
+ [](OpOperand &operand) { return &operand; });
};
auto getAlgebraicOpResult = [](Operation *op) {
auto algebraicOp = llvm::cast<AlgebraicOp>(op);
diff --git a/mlir/lib/Analysis/FlatLinearValueConstraints.cpp b/mlir/lib/Analysis/FlatLinearValueConstraints.cpp
index 6588b53cbd9f8..0e0c5f2159382 100644
--- a/mlir/lib/Analysis/FlatLinearValueConstraints.cpp
+++ b/mlir/lib/Analysis/FlatLinearValueConstraints.cpp
@@ -530,7 +530,7 @@ std::pair<AffineMap, AffineMap> FlatLinearConstraints::getLowerAndUpperBound(
// i - j + 1 >= 0 is the constraint, 'pos' is for i the lower bound is j
// - 1.
addCoeffs(ineq, lb);
- std::transform(lb.begin(), lb.end(), lb.begin(), std::negate<int64_t>());
+ llvm::transform(lb, lb.begin(), std::negate<int64_t>());
auto expr =
getAffineExprFromFlatForm(lb, dimCount, symCount, localExprs, context);
// expr ceildiv divisor is (expr + divisor - 1) floordiv divisor
@@ -559,7 +559,7 @@ std::pair<AffineMap, AffineMap> FlatLinearConstraints::getLowerAndUpperBound(
auto eq = getEquality64(idx);
addCoeffs(eq, b);
if (eq[pos + offset] > 0)
- std::transform(b.begin(), b.end(), b.begin(), std::negate<int64_t>());
+ llvm::transform(b, b.begin(), std::negate<int64_t>());
// Extract the upper bound (in terms of other coeff's + const).
auto expr =
diff --git a/mlir/lib/Analysis/Presburger/Utils.cpp b/mlir/lib/Analysis/Presburger/Utils.cpp
index 2aaa4c033d0ce..b06a8a1b9ccf8 100644
--- a/mlir/lib/Analysis/Presburger/Utils.cpp
+++ b/mlir/lib/Analysis/Presburger/Utils.cpp
@@ -52,8 +52,8 @@ static void normalizeDivisionByGCD(MutableArrayRef<DynamicAPInt> dividend,
}
// Normalize the dividend and the denominator.
- std::transform(dividend.begin(), dividend.end(), dividend.begin(),
- [gcd](DynamicAPInt &n) { return floorDiv(n, gcd); });
+ llvm::transform(dividend, dividend.begin(),
+ [gcd](DynamicAPInt &n) { return floorDiv(n, gcd); });
divisor /= gcd;
}
@@ -331,8 +331,7 @@ presburger::getDivLowerBound(ArrayRef<DynamicAPInt> dividend,
assert(dividend[localVarIdx] == 0 &&
"Local to be set to division must have zero coeff!");
SmallVector<DynamicAPInt, 8> ineq(dividend.size());
- std::transform(dividend.begin(), dividend.end(), ineq.begin(),
- std::negate<DynamicAPInt>());
+ llvm::transform(dividend, ineq.begin(), std::negate<DynamicAPInt>());
ineq[localVarIdx] = divisor;
ineq.back() += divisor - 1;
return ineq;
@@ -522,15 +521,13 @@ void DivisionRepr::dump() const { print(llvm::errs()); }
SmallVector<DynamicAPInt, 8>
presburger::getDynamicAPIntVec(ArrayRef<int64_t> range) {
SmallVector<DynamicAPInt, 8> result(range.size());
- std::transform(range.begin(), range.end(), result.begin(),
- dynamicAPIntFromInt64);
+ llvm::transform(range, result.begin(), dynamicAPIntFromInt64);
return result;
}
SmallVector<int64_t, 8> presburger::getInt64Vec(ArrayRef<DynamicAPInt> range) {
SmallVector<int64_t, 8> result(range.size());
- std::transform(range.begin(), range.end(), result.begin(),
- int64fromDynamicAPInt);
+ llvm::transform(range, result.begin(), int64fromDynamicAPInt);
return result;
}
diff --git a/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp b/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
index b405ec2201bf8..edfae7ee96039 100644
--- a/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
+++ b/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
@@ -342,8 +342,7 @@ void FlatAffineValueConstraints::getIneqAsAffineValueMap(
if (inequality[pos] > 0)
// Lower bound.
- std::transform(bound.begin(), bound.end(), bound.begin(),
- std::negate<int64_t>());
+ llvm::transform(bound, bound.begin(), std::negate<int64_t>());
else
// Upper bound (which is exclusive).
bound.back() += 1;
diff --git a/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp b/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
index bf3810ff231da..5823914967e9c 100644
--- a/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
+++ b/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
@@ -2628,7 +2628,7 @@ static LogicalResult verifyZeroPoint(T op, Value val, const int64_t &zp,
if (!zpElemType.isInteger(8) && zp != 0) {
// convert operand to lower case for error message
std::string lower = operand;
- std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
+ llvm::transform(lower, lower.begin(), ::tolower);
return op.emitOpError()
<< lower << " zero point must be zero for non-int8 integer types";
}
diff --git a/mlir/lib/IR/PatternMatch.cpp b/mlir/lib/IR/PatternMatch.cpp
index 9332f55bd9393..f015f7c9e9066 100644
--- a/mlir/lib/IR/PatternMatch.cpp
+++ b/mlir/lib/IR/PatternMatch.cpp
@@ -80,10 +80,9 @@ Pattern::Pattern(const void *rootValue, RootKind rootKind,
if (generatedNames.empty())
return;
generatedOps.reserve(generatedNames.size());
- std::transform(generatedNames.begin(), generatedNames.end(),
- std::back_inserter(generatedOps), [context](StringRef name) {
- return OperationName(name, context);
- });
+ llvm::transform(
+ generatedNames, std::back_inserter(generatedOps),
+ [context](StringRef name) { return OperationName(name, context); });
}
//===----------------------------------------------------------------------===//
More information about the Mlir-commits
mailing list