86 lines · plain
1// Check that the wide integer addition emulation produces the same result as2// wide addition. Emulate i16 ops with i8 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=8" \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 i8 types.18func.func @emulate_addi(%lhs : i16, %rhs : i16) -> (i16) {19 %res = arith.addi %lhs, %rhs : i1620 return %res : i1621}22 23func.func @check_addi(%lhs : i16, %rhs : i16) -> () {24 %res = func.call @emulate_addi(%lhs, %rhs) : (i16, i16) -> (i16)25 vector.print %res : i1626 return27}28 29func.func @entry() {30 %cst0 = arith.constant 0 : i1631 %cst1 = arith.constant 1 : i1632 %cst_n1 = arith.constant -1 : i1633 %cst_n3 = arith.constant -3 : i1634 35 %cst13 = arith.constant 13 : i1636 %cst37 = arith.constant 37 : i1637 %cst42 = arith.constant 42 : i1638 39 %cst256 = arith.constant 256 : i1640 %cst_i16_max = arith.constant 32767 : i1641 %cst_i16_min = arith.constant -32768 : i1642 43 // CHECK: 044 func.call @check_addi(%cst0, %cst0) : (i16, i16) -> ()45 // CHECK-NEXT: 146 func.call @check_addi(%cst0, %cst1) : (i16, i16) -> ()47 // CHECK-NEXT: 248 func.call @check_addi(%cst1, %cst1) : (i16, i16) -> ()49 // CHECK-NEXT: 050 func.call @check_addi(%cst1, %cst_n1) : (i16, i16) -> ()51 // CHECK-NEXT: -252 func.call @check_addi(%cst_n1, %cst_n1) : (i16, i16) -> ()53 // CHECK-NEXT: -254 func.call @check_addi(%cst1, %cst_n3) : (i16, i16) -> ()55 56 // CHECK-NEXT: 2657 func.call @check_addi(%cst13, %cst13) : (i16, i16) -> ()58 // CHECK-NEXT: 5059 func.call @check_addi(%cst13, %cst37) : (i16, i16) -> ()60 // CHECK-NEXT: 7961 func.call @check_addi(%cst37, %cst42) : (i16, i16) -> ()62 63 // CHECK-NEXT: 25564 func.call @check_addi(%cst_n1, %cst256) : (i16, i16) -> ()65 // CHECK-NEXT: 26966 func.call @check_addi(%cst256, %cst13) : (i16, i16) -> ()67 // CHECK-NEXT: 29368 func.call @check_addi(%cst256, %cst37) : (i16, i16) -> ()69 // CHECK-NEXT: 25370 func.call @check_addi(%cst256, %cst_n3) : (i16, i16) -> ()71 72 // CHECK-NEXT: -3275673 func.call @check_addi(%cst13, %cst_i16_max) : (i16, i16) -> ()74 // CHECK-NEXT: -3273175 func.call @check_addi(%cst_i16_min, %cst37) : (i16, i16) -> ()76 77 // CHECK-NEXT: -278 func.call @check_addi(%cst_i16_max, %cst_i16_max) : (i16, i16) -> ()79 // CHECK-NEXT: -3275580 func.call @check_addi(%cst_i16_min, %cst13) : (i16, i16) -> ()81 // CHECK-NEXT: 082 func.call @check_addi(%cst_i16_min, %cst_i16_min) : (i16, i16) -> ()83 84 return85}86