[Mlir-commits] [mlir] [mlir][gpu] Support arith.truncf in subgroup MMA elementwise ops (PR #182499)
Jakub Kuderski
llvmlistbot at llvm.org
Tue Feb 24 06:14:31 PST 2026
================
@@ -239,38 +239,29 @@ static bool integerExtendSupportsMMAMatrixType(ExtOpTy extOp) {
}
static bool fpExtendSupportsMMAMatrixType(arith::ExtFOp extOp) { return true; }
+static bool fpTruncSupportsMMAMatrixType(arith::TruncFOp extOp) { return true; }
/// Return the MMA elementwise enum associated with `op` if it is supported.
/// Return `std::nullopt` otherwise.
static std::optional<gpu::MMAElementwiseOp>
convertElementwiseOpToMMA(Operation *op) {
- if (isa<arith::AddFOp>(op))
- return gpu::MMAElementwiseOp::ADDF;
- if (isa<arith::MulFOp>(op))
- return gpu::MMAElementwiseOp::MULF;
- if (isa<arith::SubFOp>(op))
- return gpu::MMAElementwiseOp::SUBF;
- if (isa<arith::MaximumFOp>(op))
- return gpu::MMAElementwiseOp::MAXF;
- if (isa<arith::MinimumFOp>(op))
- return gpu::MMAElementwiseOp::MINF;
- if (isa<arith::DivFOp>(op))
- return gpu::MMAElementwiseOp::DIVF;
- if (isa<arith::AddIOp>(op))
- return gpu::MMAElementwiseOp::ADDI;
- if (isa<arith::MulIOp>(op))
- return gpu::MMAElementwiseOp::MULI;
- if (isa<arith::SubIOp>(op))
- return gpu::MMAElementwiseOp::SUBI;
- if (isa<arith::DivSIOp>(op))
- return gpu::MMAElementwiseOp::DIVS;
- if (isa<arith::DivUIOp>(op))
- return gpu::MMAElementwiseOp::DIVU;
- if (isa<arith::NegFOp>(op))
- return gpu::MMAElementwiseOp::NEGATEF;
- if (isa<arith::ExtFOp>(op))
- return gpu::MMAElementwiseOp::EXTF;
- return std::nullopt;
+ using MMAEwO = gpu::MMAElementwiseOp;
+ return TypeSwitch<Operation *, std::optional<MMAEwO>>(op)
+ .Case<arith::AddFOp>([](auto) { return MMAEwO::ADDF; })
----------------
kuhar wrote:
You don't need the template parameter if you use a concrete type for the lambda argument
https://github.com/llvm/llvm-project/pull/182499
More information about the Mlir-commits
mailing list