101 lines · plain
1// Check that the wide integer `arith.shrsi` emulation produces the same result as wide2// `arith.shrsi`. 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_shrsi(%lhs : i16, %rhs : i16) -> (i16) {19 %res = arith.shrsi %lhs, %rhs : i1620 return %res : i1621}22 23func.func @check_shrsi(%lhs : i16, %rhs : i16) -> () {24 %res = func.call @emulate_shrsi(%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 %cst2 = arith.constant 2 : i1633 %cst7 = arith.constant 7 : i1634 %cst8 = arith.constant 8 : i1635 %cst9 = arith.constant 9 : i1636 %cst15 = arith.constant 15 : i1637 38 %cst_n1 = arith.constant -1 : i1639 40 %cst1337 = arith.constant 1337 : i1641 %cst_n1337 = arith.constant -1337 : i1642 43 %cst_i16_min = arith.constant -32768 : i1644 45 // CHECK: -3276846 // CHECK-NEXT: -1638447 // CHECK-NEXT: -819248 // CHECK-NEXT: -25649 // CHECK-NEXT: -12850 // CHECK-NEXT: -6451 // CHECK-NEXT: -152 func.call @check_shrsi(%cst_i16_min, %cst0) : (i16, i16) -> ()53 func.call @check_shrsi(%cst_i16_min, %cst1) : (i16, i16) -> ()54 func.call @check_shrsi(%cst_i16_min, %cst2) : (i16, i16) -> ()55 func.call @check_shrsi(%cst_i16_min, %cst7) : (i16, i16) -> ()56 func.call @check_shrsi(%cst_i16_min, %cst8) : (i16, i16) -> ()57 func.call @check_shrsi(%cst_i16_min, %cst9) : (i16, i16) -> ()58 func.call @check_shrsi(%cst_i16_min, %cst15) : (i16, i16) -> ()59 60 // CHECK-NEXT: 061 // CHECK-NEXT: 062 // CHECK-NEXT: 063 // CHECK-NEXT: 164 // CHECK-NEXT: -165 // CHECK-NEXT: -166 func.call @check_shrsi(%cst0, %cst0) : (i16, i16) -> ()67 func.call @check_shrsi(%cst0, %cst1) : (i16, i16) -> ()68 func.call @check_shrsi(%cst1, %cst1) : (i16, i16) -> ()69 func.call @check_shrsi(%cst1, %cst0) : (i16, i16) -> ()70 func.call @check_shrsi(%cst_n1, %cst1) : (i16, i16) -> ()71 func.call @check_shrsi(%cst_n1, %cst15) : (i16, i16) -> ()72 73 // CHECK-NEXT: 133774 // CHECK-NEXT: 33475 // CHECK-NEXT: 1076 // CHECK-NEXT: 577 // CHECK-NEXT: 278 // CHECK-NEXT: 079 func.call @check_shrsi(%cst1337, %cst0) : (i16, i16) -> ()80 func.call @check_shrsi(%cst1337, %cst2) : (i16, i16) -> ()81 func.call @check_shrsi(%cst1337, %cst7) : (i16, i16) -> ()82 func.call @check_shrsi(%cst1337, %cst8) : (i16, i16) -> ()83 func.call @check_shrsi(%cst1337, %cst9) : (i16, i16) -> ()84 func.call @check_shrsi(%cst1337, %cst15) : (i16, i16) -> ()85 86 // CHECK-NEXT: -133787 // CHECK-NEXT: -33588 // CHECK-NEXT: -1189 // CHECK-NEXT: -690 // CHECK-NEXT: -391 // CHECK-NEXT: -192 func.call @check_shrsi(%cst_n1337, %cst0) : (i16, i16) -> ()93 func.call @check_shrsi(%cst_n1337, %cst2) : (i16, i16) -> ()94 func.call @check_shrsi(%cst_n1337, %cst7) : (i16, i16) -> ()95 func.call @check_shrsi(%cst_n1337, %cst8) : (i16, i16) -> ()96 func.call @check_shrsi(%cst_n1337, %cst9) : (i16, i16) -> ()97 func.call @check_shrsi(%cst_n1337, %cst15) : (i16, i16) -> ()98 99 return100}101