[Mlir-commits] [mlir] [mlir][arith] wide integer emulation support for fpto*i ops (PR #132375)
Jakub Kuderski
llvmlistbot at llvm.org
Fri Mar 21 07:48:45 PDT 2025
================
@@ -0,0 +1,82 @@
+// Check that the wide integer `arith.fptosi` emulation produces the same result as wide
+// `arith.fptosi`. Emulate i64 ops with i32 ops.
+
+// RUN: mlir-opt %s --convert-scf-to-cf --convert-cf-to-llvm --convert-vector-to-llvm \
+// RUN: --convert-func-to-llvm --convert-arith-to-llvm | \
+// RUN: mlir-cpu-runner -e entry -entry-point-result=void \
+// RUN: --shared-libs=%mlir_c_runner_utils | \
+// RUN: FileCheck %s --match-full-lines
+
+// RUN: mlir-opt %s --test-arith-emulate-wide-int="widest-int-supported=32" \
+// RUN: --convert-scf-to-cf --convert-cf-to-llvm --convert-vector-to-llvm \
+// RUN: --convert-func-to-llvm --convert-arith-to-llvm | \
+// RUN: mlir-cpu-runner -e entry -entry-point-result=void \
+// RUN: --shared-libs=%mlir_c_runner_utils | \
+// RUN: FileCheck %s --match-full-lines
+
+// Ops in this function *only* will be emulated using i32 types.
+func.func @emulate_fptosi(%arg: f64) -> i64 {
+ %res = arith.fptosi %arg : f64 to i64
+ return %res : i64
+}
+
+func.func @check_fptosi(%arg : f64) -> () {
+ %res = func.call @emulate_fptosi(%arg) : (f64) -> (i64)
+ vector.print %res : i64
+ return
+}
+
+func.func @entry() {
----------------
kuhar wrote:
Nice, thanks for testing this
https://github.com/llvm/llvm-project/pull/132375
More information about the Mlir-commits
mailing list