brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.4 KiB · 05423b7 Raw
104 lines · plain
1// Ops in this function will be emulated using i16 types.2 3// RUN: mlir-opt %s --convert-scf-to-cf --convert-cf-to-llvm --convert-vector-to-llvm \4// RUN:             --convert-func-to-llvm --convert-arith-to-llvm | \5// RUN:   mlir-runner -e entry -entry-point-result=void \6// RUN:                   --shared-libs=%mlir_c_runner_utils | \7// RUN:   FileCheck %s --match-full-lines8 9// RUN: mlir-opt %s --test-arith-emulate-wide-int="widest-int-supported=16" \10// RUN:             --convert-scf-to-cf --convert-cf-to-llvm --convert-vector-to-llvm \11// RUN:             --convert-func-to-llvm --convert-arith-to-llvm | \12// RUN:   mlir-runner -e entry -entry-point-result=void \13// RUN:                   --shared-libs=%mlir_c_runner_utils | \14// RUN:   FileCheck %s --match-full-lines15 16func.func @emulate_subi(%arg: i32, %arg0: i32) -> i32 {17  %res = arith.subi %arg, %arg0 : i3218  return %res : i3219}20 21func.func @check_subi(%arg : i32, %arg0 : i32) -> () {22  %res = func.call @emulate_subi(%arg, %arg0) : (i32, i32) -> (i32)23  vector.print %res : i3224  return25}26 27func.func @entry() {28  %lhs1 = arith.constant 1 : i3229  %rhs1 = arith.constant 2 : i3230 31  // CHECK:       -132  func.call @check_subi(%lhs1, %rhs1) : (i32, i32) -> ()33  // CHECK-NEXT:  134  func.call @check_subi(%rhs1, %lhs1) : (i32, i32) -> ()35 36  %lhs2 = arith.constant 1 : i3237  %rhs2 = arith.constant -2 : i3238 39  // CHECK-NEXT:  340  func.call @check_subi(%lhs2, %rhs2) : (i32, i32) -> ()41  // CHECK-NEXT:  -342  func.call @check_subi(%rhs2, %lhs2) : (i32, i32) -> ()43 44  %lhs3 = arith.constant -1 : i3245  %rhs3 = arith.constant -2 : i3246 47  // CHECK-NEXT:  148  func.call @check_subi(%lhs3, %rhs3) : (i32, i32) -> ()49  // CHECK-NEXT:  -150  func.call @check_subi(%rhs3, %lhs3) : (i32, i32) -> ()51 52  // Overflow from the upper/lower part.53  %lhs4 = arith.constant 131074 : i3254  %rhs4 = arith.constant 3 : i3255 56  // CHECK-NEXT:  13107157  func.call @check_subi(%lhs4, %rhs4) : (i32, i32) -> ()58  // CHECK-NEXT:  -13107159  func.call @check_subi(%rhs4, %lhs4) : (i32, i32) -> ()60 61  // Overflow in both parts.62  %lhs5 = arith.constant 16385027 : i3263  %rhs5 = arith.constant 16450564 : i3264 65  // CHECK-NEXT:  -6553766  func.call @check_subi(%lhs5, %rhs5) : (i32, i32) -> ()67  // CHECK-NEXT:  6553768  func.call @check_subi(%rhs5, %lhs5) : (i32, i32) -> ()69 70  %lhs6 = arith.constant 65536 : i3271  %rhs6 = arith.constant 1 : i3272 73  // CHECK-NEXT:  6553574  func.call @check_subi(%lhs6, %rhs6) : (i32, i32) -> ()75  // CHECK-NEXT:  -6553576  func.call @check_subi(%rhs6, %lhs6) : (i32, i32) -> ()77 78  // Max/Min (un)signed integers.79  %sintmax = arith.constant 2147483647 : i3280  %sintmin = arith.constant -2147483648 : i3281  %uintmax = arith.constant -1 : i3282  %uintmin = arith.constant 0 : i3283  %cst1 = arith.constant 1 : i3284 85  // CHECK-NEXT:  -186  func.call @check_subi(%sintmax, %sintmin) : (i32, i32) -> ()87  // CHECK-NEXT:  188  func.call @check_subi(%sintmin, %sintmax) : (i32, i32) -> ()89  // CHECK-NEXT:  214748364790  func.call @check_subi(%sintmin, %cst1) : (i32, i32) -> ()91  // CHECK-NEXT:  -214748364892  func.call @check_subi(%sintmax, %uintmax) : (i32, i32) -> ()93  // CHECK-NEXT:  -294  func.call @check_subi(%uintmax, %cst1) : (i32, i32) -> ()95  // CHECK-NEXT:  096  func.call @check_subi(%uintmax, %uintmax) : (i32, i32) -> ()97  // CHECK-NEXT:  -198  func.call @check_subi(%uintmin, %cst1) : (i32, i32) -> ()99  // CHECK-NEXT:  1100  func.call @check_subi(%uintmin, %uintmax) : (i32, i32) -> ()101 102  return103}104