[Mlir-commits] [mlir] [mlir][arith] Remove redundant lambdas (NFC) (PR #194376)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Apr 27 06:57:55 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-arith
Author: Longsheng Mou (CoTinker)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/194376.diff
1 Files Affected:
- (modified) mlir/lib/Dialect/Arith/IR/ArithOps.cpp (+11-29)
``````````diff
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);
}
//===----------------------------------------------------------------------===//
``````````
</details>
https://github.com/llvm/llvm-project/pull/194376
More information about the Mlir-commits
mailing list