[Mlir-commits] [mlir] [MLIR][NVVM] Add new narrow FP convert Ops (PR #184291)
Srinivasa Ravi
llvmlistbot at llvm.org
Thu Mar 5 21:19:33 PST 2026
================
@@ -1994,6 +2033,43 @@ def NVVM_ConvertF32x2ToF6x2Op : NVVM_Op<"convert.f32x2.to.f6x2"> {
}];
}
+class NVVM_ConvertFPx2ToF6x2Op<string srcType>
+ : NVVM_Op<"convert."#!tolower(srcType)#"x2.to.f6x2"> {
+ let summary = "Convert a pair of "#srcType#" inputs to F6x2";
+ let description = [{
+ This Op converts each of the given }]#srcType#[{ inputs to the specified
+ F6x2 type.
+ The result `dst` is represented as a vector type(vector<2xi8>). Each
+ converted value is stored as an i8 element in the vector.
+ The `relu` attribute, when set, lowers to the '.relu' variant of
+ the cvt instruction.
+ }];
+
+ let hasVerifier = 1;
+ let results = (outs AnyTypeOf<[I16, VectorOfLengthAndType<[2], [I8]>]>:$dst);
+ let arguments = (ins
+ VectorOfLengthAndType<[2], [!cast<Type>(srcType)]>:$a,
+ DefaultValuedAttr<BoolAttr, "false">:$relu,
+ TypeAttr:$dstTy);
+ let assemblyFormat = "$a attr-dict `:` type($a) `->` type($dst) `(` $dstTy `)`";
+ let extraClassDeclaration = [{
+ static llvm::Intrinsic::ID getIntrinsicID(mlir::Type dstTy, bool hasRelu);
+ }];
+
+ string llvmBuilder = [{
+ auto intId = NVVM::Convert}]#srcType#[{x2ToF6x2Op::getIntrinsicID($dstTy, $relu);
+ llvm::Value *packedI16 = createIntrinsicCall(builder, intId, {$a});
+ if(op.getDst().getType().isInteger(16))
+ $dst = packedI16;
+ else
+ $dst = builder.CreateBitCast(packedI16,
----------------
Wolfram70 wrote:
We perform the bitcast to `<2xi8>` here in the conversion Ops just so that the abstractions in the higher-level dialects become a bit simpler to write. Since the bitcast is effectively a no-op, handling it here seemed reasonable.
https://github.com/llvm/llvm-project/pull/184291
More information about the Mlir-commits
mailing list