brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.4 KiB · 0bce669 Raw
89 lines · plain
1// Check that the wide integer `arith.fptosi` emulation produces the same result as wide2// `arith.fptosi`. Emulate i64 ops with i32 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=32" \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 i32 types.18func.func @emulate_fptosi(%arg: f64) -> i64 {19  %res = arith.fptosi %arg : f64 to i6420  return %res : i6421}22 23func.func @check_fptosi(%arg : f64) -> () {24  %res = func.call @emulate_fptosi(%arg) : (f64) -> (i64)25  vector.print %res : i6426  return27}28 29func.func @entry() {30  %cst0 = arith.constant 0.0 : f6431  %cst_nzero = arith.constant 0x8000000000000000 : f6432  %cst1 = arith.constant 1.0 : f6433  %cst_n1 = arith.constant -1.0 : f6434  %cst_n1_5 = arith.constant -1.5 : f6435 36  %cstpow20 = arith.constant 1048576.0 : f6437  %cstnpow20 = arith.constant -1048576.0 : f6438 39  %cst_i32_max = arith.constant 4294967295.0 : f6440  %cst_i32_min = arith.constant -4294967296.0 : f6441  %cst_i32_overflow = arith.constant 4294967296.0 : f6442  %cst_i32_noverflow = arith.constant -4294967297.0 : f6443 44  %cstpow40 = arith.constant 1099511627776.0 : f6445  %cstnpow40 = arith.constant -1099511627776.0 : f6446  %cst_pow40ppow20 = arith.constant 1099512676352.0 : f6447  %cst_npow40ppow20 = arith.constant -1099512676352.0 : f6448 49  %cst_max = arith.constant 9007199254740992.050  %cst_min = arith.constant -9007199254740992.051 52  // CHECK:         053  func.call @check_fptosi(%cst0) : (f64) -> ()54  // CHECK-NEXT:    055  func.call @check_fptosi(%cst_nzero) : (f64) -> ()56  // CHECK-NEXT:    157  func.call @check_fptosi(%cst1) : (f64) -> ()58  // CHECK-NEXT:    -159  func.call @check_fptosi(%cst_n1) : (f64) -> ()60  // CHECK-NEXT:    -161  func.call @check_fptosi(%cst_n1_5) : (f64) -> ()62  // CHECK-NEXT:    104857663  func.call @check_fptosi(%cstpow20) : (f64) -> ()64  // CHECK-NEXT:    -104857665  func.call @check_fptosi(%cstnpow20) : (f64) -> ()66  // CHECK-NEXT:    429496729567  func.call @check_fptosi(%cst_i32_max) : (f64) -> ()68  // CHECK-NEXT:    -429496729669  func.call @check_fptosi(%cst_i32_min) : (f64) -> ()70  // CHECK-NEXT:    429496729671  func.call @check_fptosi(%cst_i32_overflow) : (f64) -> ()72  // CHECK-NEXT:    -429496729773  func.call @check_fptosi(%cst_i32_noverflow) : (f64) -> ()74  // CHECK-NEXT:    109951162777675  func.call @check_fptosi(%cstpow40) : (f64) -> ()76  // CHECK-NEXT:    -109951162777677  func.call @check_fptosi(%cstnpow40) : (f64) -> ()78  // CHECK-NEXT:    109951267635279  func.call @check_fptosi(%cst_pow40ppow20) : (f64) -> ()80  // CHECK-NEXT:    -109951267635281  func.call @check_fptosi(%cst_npow40ppow20) : (f64) -> ()82  // CHECK-NEXT:    900719925474099283  func.call @check_fptosi(%cst_max) : (f64) -> ()84  // CHECK-NEXT:    -900719925474099285  func.call @check_fptosi(%cst_min) : (f64) -> ()86 87  return88}89