[Mlir-commits] [mlir] [MLIR][Arith] expand-ops: Support mini/maxi (PR #90575)
Jakub Kuderski
llvmlistbot at llvm.org
Tue Apr 30 08:03:51 PDT 2024
================
@@ -152,6 +152,23 @@ struct FloorDivSIOpConverter : public OpRewritePattern<arith::FloorDivSIOp> {
}
};
+template <typename OpTy, arith::CmpIPredicate pred>
+struct MaxMinIOpConverter : public OpRewritePattern<OpTy> {
+public:
+ using OpRewritePattern<OpTy>::OpRewritePattern;
+
+ LogicalResult matchAndRewrite(OpTy op,
+ PatternRewriter &rewriter) const final {
+ Value lhs = op.getLhs();
+ Value rhs = op.getRhs();
+
+ Location loc = op.getLoc();
+ Value cmp = rewriter.create<arith::CmpIOp>(loc, pred, lhs, rhs);
----------------
kuhar wrote:
nit: since there's only one use of `loc` this could be inlined
```suggestion
Value cmp = rewriter.create<arith::CmpIOp>(op.getLoc(), pred, lhs, rhs);
```
https://github.com/llvm/llvm-project/pull/90575
More information about the Mlir-commits
mailing list