[mlir][arith] Remove redundant lambdas (NFC)#194376
Merged
Merged
Conversation
Replace trivial lambda wrappers with direct function references. The lambdas simply forwarded their arguments to existing functions, so passing the function directly is clearer and more concise.
Member
|
@llvm/pr-subscribers-mlir @llvm/pr-subscribers-mlir-arith Author: Longsheng Mou (CoTinker) ChangesReplace trivial lambda wrappers with direct function references. The lambdas simply forwarded their arguments to existing functions, so passing the function directly is clearer and more concise. Full diff: https://github.com/llvm/llvm-project/pull/194376.diff 1 Files Affected:
diff --git a/mlir/lib/Dialect/Arith/IR/ArithOps.cpp b/mlir/lib/Dialect/Arith/IR/ArithOps.cpp
index 36d0f093c6917..ae0bf6bb0e90b 100644
--- a/mlir/lib/Dialect/Arith/IR/ArithOps.cpp
+++ b/mlir/lib/Dialect/Arith/IR/ArithOps.cpp
@@ -611,10 +611,8 @@ arith::MulSIExtendedOp::fold(FoldAdaptor adaptor,
adaptor.getOperands(),
[](const APInt &a, const APInt &b) { return a * b; })) {
// Invoke the constant fold helper again to calculate the 'high' result.
- Attribute highAttr = constFoldBinaryOp<IntegerAttr>(
- adaptor.getOperands(), [](const APInt &a, const APInt &b) {
- return llvm::APIntOps::mulhs(a, b);
- });
+ Attribute highAttr = constFoldBinaryOp<IntegerAttr>(adaptor.getOperands(),
+ llvm::APIntOps::mulhs);
assert(highAttr && "Unexpected constant-folding failure");
results.push_back(lowAttr);
@@ -666,10 +664,8 @@ arith::MulUIExtendedOp::fold(FoldAdaptor adaptor,
adaptor.getOperands(),
[](const APInt &a, const APInt &b) { return a * b; })) {
// Invoke the constant fold helper again to calculate the 'high' result.
- Attribute highAttr = constFoldBinaryOp<IntegerAttr>(
- adaptor.getOperands(), [](const APInt &a, const APInt &b) {
- return llvm::APIntOps::mulhu(a, b);
- });
+ Attribute highAttr = constFoldBinaryOp<IntegerAttr>(adaptor.getOperands(),
+ llvm::APIntOps::mulhu);
assert(highAttr && "Unexpected constant-folding failure");
results.push_back(lowAttr);
@@ -1180,9 +1176,7 @@ OpFoldResult arith::MaximumFOp::fold(FoldAdaptor adaptor) {
if (matchPattern(adaptor.getRhs(), m_NegInfFloat()))
return getLhs();
- return constFoldBinaryOp<FloatAttr>(
- adaptor.getOperands(),
- [](const APFloat &a, const APFloat &b) { return llvm::maximum(a, b); });
+ return constFoldBinaryOp<FloatAttr>(adaptor.getOperands(), llvm::maximum);
}
//===----------------------------------------------------------------------===//
@@ -1221,9 +1215,7 @@ OpFoldResult MaxSIOp::fold(FoldAdaptor adaptor) {
}
return constFoldBinaryOp<IntegerAttr>(adaptor.getOperands(),
- [](const APInt &a, const APInt &b) {
- return llvm::APIntOps::smax(a, b);
- });
+ llvm::APIntOps::smax);
}
//===----------------------------------------------------------------------===//
@@ -1246,9 +1238,7 @@ OpFoldResult MaxUIOp::fold(FoldAdaptor adaptor) {
}
return constFoldBinaryOp<IntegerAttr>(adaptor.getOperands(),
- [](const APInt &a, const APInt &b) {
- return llvm::APIntOps::umax(a, b);
- });
+ llvm::APIntOps::umax);
}
//===----------------------------------------------------------------------===//
@@ -1264,9 +1254,7 @@ OpFoldResult arith::MinimumFOp::fold(FoldAdaptor adaptor) {
if (matchPattern(adaptor.getRhs(), m_PosInfFloat()))
return getLhs();
- return constFoldBinaryOp<FloatAttr>(
- adaptor.getOperands(),
- [](const APFloat &a, const APFloat &b) { return llvm::minimum(a, b); });
+ return constFoldBinaryOp<FloatAttr>(adaptor.getOperands(), llvm::minimum);
}
//===----------------------------------------------------------------------===//
@@ -1282,9 +1270,7 @@ OpFoldResult arith::MinNumFOp::fold(FoldAdaptor adaptor) {
if (matchPattern(adaptor.getRhs(), m_NaNFloat()))
return getLhs();
- return constFoldBinaryOp<FloatAttr>(
- adaptor.getOperands(),
- [](const APFloat &a, const APFloat &b) { return llvm::minnum(a, b); });
+ return constFoldBinaryOp<FloatAttr>(adaptor.getOperands(), llvm::minnum);
}
//===----------------------------------------------------------------------===//
@@ -1307,9 +1293,7 @@ OpFoldResult MinSIOp::fold(FoldAdaptor adaptor) {
}
return constFoldBinaryOp<IntegerAttr>(adaptor.getOperands(),
- [](const APInt &a, const APInt &b) {
- return llvm::APIntOps::smin(a, b);
- });
+ llvm::APIntOps::smin);
}
//===----------------------------------------------------------------------===//
@@ -1332,9 +1316,7 @@ OpFoldResult MinUIOp::fold(FoldAdaptor adaptor) {
}
return constFoldBinaryOp<IntegerAttr>(adaptor.getOperands(),
- [](const APInt &a, const APInt &b) {
- return llvm::APIntOps::umin(a, b);
- });
+ llvm::APIntOps::umin);
}
//===----------------------------------------------------------------------===//
|
joker-eph
approved these changes
Apr 28, 2026
yingopq
pushed a commit
to yingopq/llvm-project
that referenced
this pull request
Apr 29, 2026
Replace trivial lambda wrappers with direct function references. The lambdas simply forwarded their arguments to existing functions, so passing the function directly is clearer and more concise.
KHicketts
pushed a commit
to KHicketts/llvm-project
that referenced
this pull request
Apr 30, 2026
Replace trivial lambda wrappers with direct function references. The lambdas simply forwarded their arguments to existing functions, so passing the function directly is clearer and more concise.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace trivial lambda wrappers with direct function references. The lambdas simply forwarded their arguments to existing functions, so passing the function directly is clearer and more concise.