78 lines · plain
1// Check that the wide integer `arith.uitofp` emulation produces the same result as wide2// `arith.uitofp`. 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_uitofp(%arg: i32) -> f32 {19 %res = arith.uitofp %arg : i32 to f3220 return %res : f3221}22 23func.func @check_uitofp(%arg : i32) -> () {24 %res = func.call @emulate_uitofp(%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 %cst_i16_max = arith.constant 65535 : i3236 %cst_i16_overflow = arith.constant 65536 : i3237 38 %cst_n1 = arith.constant -1 : i3239 %cst_n13 = arith.constant -13 : i3240 %cst_n1337 = arith.constant -1337 : i3241 42 %cst_i16_min = arith.constant -32768 : i3243 44 %cst_f32_int_max = arith.constant 16777217 : i3245 %cst_f32_int_min = arith.constant -16777217 : i3246 47 // CHECK: 048 func.call @check_uitofp(%cst0) : (i32) -> ()49 // CHECK-NEXT: 150 func.call @check_uitofp(%cst1) : (i32) -> ()51 // CHECK-NEXT: 252 func.call @check_uitofp(%cst2) : (i32) -> ()53 // CHECK-NEXT: 754 func.call @check_uitofp(%cst7) : (i32) -> ()55 // CHECK-NEXT: 133756 func.call @check_uitofp(%cst1337) : (i32) -> ()57 // CHECK-NEXT: 6553558 func.call @check_uitofp(%cst_i16_max) : (i32) -> ()59 // CHECK-NEXT: 6553660 func.call @check_uitofp(%cst_i16_overflow) : (i32) -> ()61 62 // CHECK-NEXT: 4.2{{.+}}e+0963 func.call @check_uitofp(%cst_n1) : (i32) -> ()64 // CHECK-NEXT: 4.2{{.+}}e+0965 func.call @check_uitofp(%cst_n1337) : (i32) -> ()66 67 // CHECK-NEXT: 4.2{{.+}}e+0968 func.call @check_uitofp(%cst_i16_min) : (i32) -> ()69 // CHECK-NEXT: 4.2{{.+}}e+0970 func.call @check_uitofp(%cst_i16_min) : (i32) -> ()71 // CHECK-NEXT: 1.6{{.+}}e+0772 func.call @check_uitofp(%cst_f32_int_max) : (i32) -> ()73 // CHECK-NEXT: 4.2{{.+}}e+0974 func.call @check_uitofp(%cst_f32_int_min) : (i32) -> ()75 76 return77}78