69 lines · plain
1// Check that the wide integer `arith.sitofp` emulation produces the same result as wide2// `arith.sitofp`. Emulate i32 ops with i16 ops.3 4// RUN: mlir-opt %s --convert-scf-to-cf --convert-cf-to-llvm --convert-vector-to-llvm \5// RUN: --convert-func-to-llvm --convert-arith-to-llvm | \6// RUN: mlir-runner -e entry -entry-point-result=void \7// RUN: --shared-libs=%mlir_c_runner_utils | \8// RUN: FileCheck %s --match-full-lines9 10// RUN: mlir-opt %s --test-arith-emulate-wide-int="widest-int-supported=16" \11// RUN: --convert-scf-to-cf --convert-cf-to-llvm --convert-vector-to-llvm \12// RUN: --convert-func-to-llvm --convert-arith-to-llvm | \13// RUN: mlir-runner -e entry -entry-point-result=void \14// RUN: --shared-libs=%mlir_c_runner_utils | \15// RUN: FileCheck %s --match-full-lines16 17// Ops in this function *only* will be emulated using i16 types.18func.func @emulate_sitofp(%arg: i32) -> f32 {19 %res = arith.sitofp %arg : i32 to f3220 return %res : f3221}22 23func.func @check_sitofp(%arg : i32) -> () {24 %res = func.call @emulate_sitofp(%arg) : (i32) -> (f32)25 vector.print %res : f3226 return27}28 29func.func @entry() {30 %cst0 = arith.constant 0 : i3231 %cst1 = arith.constant 1 : i3232 %cst2 = arith.constant 2 : i3233 %cst7 = arith.constant 7 : i3234 %cst1337 = arith.constant 1337 : i3235 36 %cst_n1 = arith.constant -1 : i3237 %cst_n13 = arith.constant -13 : i3238 %cst_n1337 = arith.constant -1337 : i3239 40 %cst_i16_min = arith.constant -32768 : i3241 42 %cst_f32_int_max = arith.constant 16777217 : i3243 %cst_f32_int_min = arith.constant -16777217 : i3244 45 // CHECK: 046 func.call @check_sitofp(%cst0) : (i32) -> ()47 // CHECK-NEXT: 148 func.call @check_sitofp(%cst1) : (i32) -> ()49 // CHECK-NEXT: 250 func.call @check_sitofp(%cst2) : (i32) -> ()51 // CHECK-NEXT: 752 func.call @check_sitofp(%cst7) : (i32) -> ()53 // CHECK-NEXT: 133754 func.call @check_sitofp(%cst1337) : (i32) -> ()55 // CHECK-NEXT: -156 func.call @check_sitofp(%cst_n1) : (i32) -> ()57 // CHECK-NEXT: -133758 func.call @check_sitofp(%cst_n1337) : (i32) -> ()59 60 // CHECK-NEXT: -3276861 func.call @check_sitofp(%cst_i16_min) : (i32) -> ()62 // CHECK-NEXT: 1.6{{.+}}e+0763 func.call @check_sitofp(%cst_f32_int_max) : (i32) -> ()64 // CHECK-NEXT: -1.6{{.+}}e+0765 func.call @check_sitofp(%cst_f32_int_min) : (i32) -> ()66 67 return68}69