74 lines · plain
1// Check that the wide integer `arith.shli` emulation produces the same result as wide2// `arith.shli`. 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_shli(%lhs : i16, %rhs : i16) -> (i16) {19 %res = arith.shli %lhs, %rhs : i1620 return %res : i1621}22 23func.func @check_shli(%lhs : i16, %rhs : i16) -> () {24 %res = func.call @emulate_shli(%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 42 %cst_i16_min = arith.constant -32768 : i1643 44 // CHECK: 045 // CHECK-NEXT: 046 // CHECK-NEXT: 147 // CHECK-NEXT: 248 // CHECK-NEXT: -249 // CHECK-NEXT: -3276850 func.call @check_shli(%cst0, %cst0) : (i16, i16) -> ()51 func.call @check_shli(%cst0, %cst1) : (i16, i16) -> ()52 func.call @check_shli(%cst1, %cst0) : (i16, i16) -> ()53 func.call @check_shli(%cst1, %cst1) : (i16, i16) -> ()54 func.call @check_shli(%cst_n1, %cst1) : (i16, i16) -> ()55 func.call @check_shli(%cst_n1, %cst15) : (i16, i16) -> ()56 57 // CHECK-NEXT: 133758 // CHECK-NEXT: 534859 // CHECK-NEXT: -2547260 // CHECK-NEXT: 1459261 // CHECK-NEXT: 2918462 // CHECK-NEXT: -3276863 // CHECK-NEXT: 064 func.call @check_shli(%cst1337, %cst0) : (i16, i16) -> ()65 func.call @check_shli(%cst1337, %cst2) : (i16, i16) -> ()66 func.call @check_shli(%cst1337, %cst7) : (i16, i16) -> ()67 func.call @check_shli(%cst1337, %cst8) : (i16, i16) -> ()68 func.call @check_shli(%cst1337, %cst9) : (i16, i16) -> ()69 func.call @check_shli(%cst1337, %cst15) : (i16, i16) -> ()70 func.call @check_shli(%cst_i16_min, %cst1) : (i16, i16) -> ()71 72 return73}74