[Mlir-commits] [mlir] [mlir][arith][transforms] Adds Truncf f32 to f4e2m1 (PR #144157)

Jakub Kuderski llvmlistbot at llvm.org
Tue Jun 17 07:44:39 PDT 2025


================
@@ -0,0 +1,58 @@
+// Check various edge cases for truncf/extf ops involving f32 and f4e2m1 types.
+
+// RUN: mlir-opt %s --convert-vector-to-llvm \
+// RUN:             --convert-func-to-llvm \
+// RUN:             --arith-expand="include-f4e2m1=true" \
+// RUN:             --convert-arith-to-llvm | \
+// RUN: mlir-runner -e entry --entry-point-result=void \
+// RUN:             --shared-libs=%mlir_c_runner_utils | \
+// RUN: FileCheck %s --match-full-lines
+
+func.func @check_extf(%in : f32) -> () {
+  %trunc = arith.truncf %in : f32 to f4E2M1FN
+  %res = arith.extf %trunc : f4E2M1FN to f32
----------------
kuhar wrote:

How can we know that this doesn't get folded immediately after? would it be safer to pass the input as f4 or some integer type that gets bitcast to f4 instead?

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


More information about the Mlir-commits mailing list