[Mlir-commits] [mlir] [MLIR][NVGPU] Add convert.fpext and convert.fptrunc Ops (PR #199700)

Srinivasa Ravi llvmlistbot at llvm.org
Wed May 27 07:09:28 PDT 2026


================
@@ -671,4 +671,80 @@ def NVGPU_RcpOp : NVGPU_Op<"rcp", [Pure,
   let hasVerifier = 1;
 }
 
+//===----------------------------------------------------------------------===//
+// NVGPU Conversion Ops
+//===----------------------------------------------------------------------===//
+
+def Int8OrFloatLike : TypeConstraint<
+    Or<[FloatLike.predicate,
+        I8.predicate,
+        ValueSemanticsContainerOf<[I8]>.predicate]>,
+    "scalar, vector, or tensor of i8 or floats">;
+def AnyI32Like : TypeOrValueSemanticsContainer<I32, "scalar i32 or vector of i32">;
+
+def NVGPU_FPTruncOp : NVGPU_Op<"convert.fptrunc",
+    [Pure]> {
+  let summary = "Truncate floating-point to narrower floating-point";
+  let description = [{
+    Truncate a floating-point value to a smaller floating-point type.
+    Destination must be strictly narrower than source.
+
+    Supported paths: f32->f16, f32->bf16, f32->f8, f32->f6, f32->f4,
+    f16->f8, f16->f4, bf16->f8, bf16->f4.
----------------
Wolfram70 wrote:

Done! Looks like these conversions are available but I'd missed them. Added these now. Currently, the only missing piece is narrow-fp to `bf16` FPExt, for which intrinsics are available. We can update `nvgpu.convert.fpext` once we add the NVVM Ops.

https://github.com/llvm/llvm-project/pull/199700


More information about the Mlir-commits mailing list