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

Durgadoss R llvmlistbot at llvm.org
Wed May 27 03:50:08 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",
----------------
durga4github wrote:

ok, thought about this some more while I was reviewing the change:

I see that we have some differences between the two Ops, that make me wonder if merging them is the correct direction here.
1)
The src/dst types supported on trunc vs. ext are not the same set of types.
2)
Some input operands are required for one but not the other.
For example, random_bits is a possible input for trunc but not for ext.
3)
The set of required `attrs` differs between the two.
For example, ext does not need `rounding-mode` attr.

I still think that we can merge and handle all these constraints through verifier-checks.
But from an IR readability point of view, keeping them separate seems cleaner.

@grypp, Please let me know what you think!

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


More information about the Mlir-commits mailing list