brintos

brintos / llvm-project-archived public Read only

0
0
Text · 12.0 KiB · a964913 Raw
345 lines · plain
1// Check that the wide integer `arith.cmpi` emulation produces the same result as wide2// `arith.cmpi`. Emulate i16 ops with i8 ops.3// Ops in functions prefixed with `emulate` will be emulated using i8 types.4 5// RUN: mlir-opt %s --convert-scf-to-cf --convert-cf-to-llvm --convert-vector-to-llvm \6// RUN:             --convert-func-to-llvm --convert-arith-to-llvm | \7// RUN:   mlir-runner -e entry -entry-point-result=void \8// RUN:                   --shared-libs=%mlir_c_runner_utils | \9// RUN:   FileCheck %s --match-full-lines10 11// RUN: mlir-opt %s --test-arith-emulate-wide-int="widest-int-supported=8" \12// RUN:             --convert-scf-to-cf --convert-cf-to-llvm --convert-vector-to-llvm \13// RUN:             --convert-func-to-llvm --convert-arith-to-llvm | \14// RUN:   mlir-runner -e entry -entry-point-result=void \15// RUN:                   --shared-libs=%mlir_c_runner_utils | \16// RUN:   FileCheck %s --match-full-lines17 18func.func @emulate_cmpi_eq(%lhs : i16, %rhs : i16) -> (i1) {19  %res = arith.cmpi eq, %lhs, %rhs : i1620  return %res : i121}22 23func.func @check_cmpi_eq(%lhs : i16, %rhs : i16) -> () {24  %res = func.call @emulate_cmpi_eq(%lhs, %rhs) : (i16, i16) -> (i1)25  vector.print %res : i126  return27}28 29func.func @emulate_cmpi_ne(%lhs : i16, %rhs : i16) -> (i1) {30  %res = arith.cmpi ne, %lhs, %rhs : i1631  return %res : i132}33 34func.func @check_cmpi_ne(%lhs : i16, %rhs : i16) -> () {35  %res = func.call @emulate_cmpi_ne(%lhs, %rhs) : (i16, i16) -> (i1)36  vector.print %res : i137  return38}39 40func.func @emulate_cmpi_sge(%lhs : i16, %rhs : i16) -> (i1) {41  %res = arith.cmpi sge, %lhs, %rhs : i1642  return %res : i143}44 45func.func @check_cmpi_sge(%lhs : i16, %rhs : i16) -> () {46  %res = func.call @emulate_cmpi_sge(%lhs, %rhs) : (i16, i16) -> (i1)47  vector.print %res : i148  return49}50 51func.func @emulate_cmpi_sgt(%lhs : i16, %rhs : i16) -> (i1) {52  %res = arith.cmpi sgt, %lhs, %rhs : i1653  return %res : i154}55 56func.func @check_cmpi_sgt(%lhs : i16, %rhs : i16) -> () {57  %res = func.call @emulate_cmpi_sgt(%lhs, %rhs) : (i16, i16) -> (i1)58  vector.print %res : i159  return60}61 62func.func @emulate_cmpi_sle(%lhs : i16, %rhs : i16) -> (i1) {63  %res = arith.cmpi sle, %lhs, %rhs : i1664  return %res : i165}66 67func.func @check_cmpi_sle(%lhs : i16, %rhs : i16) -> () {68  %res = func.call @emulate_cmpi_sle(%lhs, %rhs) : (i16, i16) -> (i1)69  vector.print %res : i170  return71}72 73func.func @emulate_cmpi_slt(%lhs : i16, %rhs : i16) -> (i1) {74  %res = arith.cmpi slt, %lhs, %rhs : i1675  return %res : i176}77 78func.func @check_cmpi_slt(%lhs : i16, %rhs : i16) -> () {79  %res = func.call @emulate_cmpi_slt(%lhs, %rhs) : (i16, i16) -> (i1)80  vector.print %res : i181  return82}83 84func.func @emulate_cmpi_uge(%lhs : i16, %rhs : i16) -> (i1) {85  %res = arith.cmpi uge, %lhs, %rhs : i1686  return %res : i187}88 89func.func @check_cmpi_uge(%lhs : i16, %rhs : i16) -> () {90  %res = func.call @emulate_cmpi_uge(%lhs, %rhs) : (i16, i16) -> (i1)91  vector.print %res : i192  return93}94 95func.func @emulate_cmpi_ugt(%lhs : i16, %rhs : i16) -> (i1) {96  %res = arith.cmpi ugt, %lhs, %rhs : i1697  return %res : i198}99 100func.func @check_cmpi_ugt(%lhs : i16, %rhs : i16) -> () {101  %res = func.call @emulate_cmpi_ugt(%lhs, %rhs) : (i16, i16) -> (i1)102  vector.print %res : i1103  return104}105 106func.func @emulate_cmpi_ule(%lhs : i16, %rhs : i16) -> (i1) {107  %res = arith.cmpi ule, %lhs, %rhs : i16108  return %res : i1109}110 111func.func @check_cmpi_ule(%lhs : i16, %rhs : i16) -> () {112  %res = func.call @emulate_cmpi_ule(%lhs, %rhs) : (i16, i16) -> (i1)113  vector.print %res : i1114  return115}116 117func.func @emulate_cmpi_ult(%lhs : i16, %rhs : i16) -> (i1) {118  %res = arith.cmpi ult, %lhs, %rhs : i16119  return %res : i1120}121 122func.func @check_cmpi_ult(%lhs : i16, %rhs : i16) -> () {123  %res = func.call @emulate_cmpi_ult(%lhs, %rhs) : (i16, i16) -> (i1)124  vector.print %res : i1125  return126}127 128func.func @entry() {129  %cst0 = arith.constant 0 : i16130  %cst1 = arith.constant 1 : i16131  %cst7 = arith.constant 7 : i16132  %cst_n1 = arith.constant -1 : i16133  %cst1337 = arith.constant 1337 : i16134  %cst4096 = arith.constant 4096 : i16135  %cst_i16_min = arith.constant -32768 : i16136 137  // CHECK:      1138  // CHECK-NEXT: 0139  // CHECK-NEXT: 0140  // CHECK-NEXT: 1141  // CHECK-NEXT: 0142  // CHECK-NEXT: 0143  // CHECK-NEXT: 1144  // CHECK-NEXT: 1145  // CHECK-NEXT: 0146  func.call @check_cmpi_eq(%cst0, %cst0) : (i16, i16) -> ()147  func.call @check_cmpi_eq(%cst0, %cst1) : (i16, i16) -> ()148  func.call @check_cmpi_eq(%cst1, %cst0) : (i16, i16) -> ()149  func.call @check_cmpi_eq(%cst1, %cst1) : (i16, i16) -> ()150  func.call @check_cmpi_eq(%cst_n1, %cst1) : (i16, i16) -> ()151  func.call @check_cmpi_eq(%cst_n1, %cst1337) : (i16, i16) -> ()152  func.call @check_cmpi_eq(%cst1337, %cst1337) : (i16, i16) -> ()153  func.call @check_cmpi_eq(%cst4096, %cst4096) : (i16, i16) -> ()154  func.call @check_cmpi_eq(%cst1337, %cst_i16_min) : (i16, i16) -> ()155 156  // CHECK-NEXT: 0157  // CHECK-NEXT: 1158  // CHECK-NEXT: 1159  // CHECK-NEXT: 0160  // CHECK-NEXT: 1161  // CHECK-NEXT: 1162  // CHECK-NEXT: 0163  // CHECK-NEXT: 0164  // CHECK-NEXT: 1165  func.call @check_cmpi_ne(%cst0, %cst0) : (i16, i16) -> ()166  func.call @check_cmpi_ne(%cst0, %cst1) : (i16, i16) -> ()167  func.call @check_cmpi_ne(%cst1, %cst0) : (i16, i16) -> ()168  func.call @check_cmpi_ne(%cst1, %cst1) : (i16, i16) -> ()169  func.call @check_cmpi_ne(%cst_n1, %cst1) : (i16, i16) -> ()170  func.call @check_cmpi_ne(%cst_n1, %cst1337) : (i16, i16) -> ()171  func.call @check_cmpi_ne(%cst1337, %cst1337) : (i16, i16) -> ()172  func.call @check_cmpi_ne(%cst4096, %cst4096) : (i16, i16) -> ()173  func.call @check_cmpi_ne(%cst1337, %cst_i16_min) : (i16, i16) -> ()174 175  // CHECK-NEXT: 1176  // CHECK-NEXT: 0177  // CHECK-NEXT: 1178  // CHECK-NEXT: 1179  // CHECK-NEXT: 0180  // CHECK-NEXT: 1181  // CHECK-NEXT: 0182  // CHECK-NEXT: 1183  // CHECK-NEXT: 1184  // CHECK-NEXT: 1185  func.call @check_cmpi_sge(%cst0, %cst0) : (i16, i16) -> ()186  func.call @check_cmpi_sge(%cst0, %cst1) : (i16, i16) -> ()187  func.call @check_cmpi_sge(%cst1, %cst0) : (i16, i16) -> ()188  func.call @check_cmpi_sge(%cst1, %cst1) : (i16, i16) -> ()189  func.call @check_cmpi_sge(%cst_n1, %cst1) : (i16, i16) -> ()190  func.call @check_cmpi_sge(%cst1, %cst_n1) : (i16, i16) -> ()191  func.call @check_cmpi_sge(%cst_n1, %cst1337) : (i16, i16) -> ()192  func.call @check_cmpi_sge(%cst1337, %cst1337) : (i16, i16) -> ()193  func.call @check_cmpi_sge(%cst4096, %cst4096) : (i16, i16) -> ()194  func.call @check_cmpi_sge(%cst1337, %cst_i16_min) : (i16, i16) -> ()195 196  // CHECK-NEXT: 0197  // CHECK-NEXT: 0198  // CHECK-NEXT: 1199  // CHECK-NEXT: 0200  // CHECK-NEXT: 0201  // CHECK-NEXT: 1202  // CHECK-NEXT: 0203  // CHECK-NEXT: 0204  // CHECK-NEXT: 0205  // CHECK-NEXT: 1206  func.call @check_cmpi_sgt(%cst0, %cst0) : (i16, i16) -> ()207  func.call @check_cmpi_sgt(%cst0, %cst1) : (i16, i16) -> ()208  func.call @check_cmpi_sgt(%cst1, %cst0) : (i16, i16) -> ()209  func.call @check_cmpi_sgt(%cst1, %cst1) : (i16, i16) -> ()210  func.call @check_cmpi_sgt(%cst_n1, %cst1) : (i16, i16) -> ()211  func.call @check_cmpi_sgt(%cst1, %cst_n1) : (i16, i16) -> ()212  func.call @check_cmpi_sgt(%cst_n1, %cst1337) : (i16, i16) -> ()213  func.call @check_cmpi_sgt(%cst1337, %cst1337) : (i16, i16) -> ()214  func.call @check_cmpi_sgt(%cst4096, %cst4096) : (i16, i16) -> ()215  func.call @check_cmpi_sgt(%cst1337, %cst_i16_min) : (i16, i16) -> ()216 217  // CHECK-NEXT: 1218  // CHECK-NEXT: 1219  // CHECK-NEXT: 0220  // CHECK-NEXT: 1221  // CHECK-NEXT: 1222  // CHECK-NEXT: 0223  // CHECK-NEXT: 1224  // CHECK-NEXT: 1225  // CHECK-NEXT: 1226  // CHECK-NEXT: 0227  func.call @check_cmpi_sle(%cst0, %cst0) : (i16, i16) -> ()228  func.call @check_cmpi_sle(%cst0, %cst1) : (i16, i16) -> ()229  func.call @check_cmpi_sle(%cst1, %cst0) : (i16, i16) -> ()230  func.call @check_cmpi_sle(%cst1, %cst1) : (i16, i16) -> ()231  func.call @check_cmpi_sle(%cst_n1, %cst1) : (i16, i16) -> ()232  func.call @check_cmpi_sle(%cst1, %cst_n1) : (i16, i16) -> ()233  func.call @check_cmpi_sle(%cst_n1, %cst1337) : (i16, i16) -> ()234  func.call @check_cmpi_sle(%cst1337, %cst1337) : (i16, i16) -> ()235  func.call @check_cmpi_sle(%cst4096, %cst4096) : (i16, i16) -> ()236  func.call @check_cmpi_sle(%cst1337, %cst_i16_min) : (i16, i16) -> ()237 238  // CHECK-NEXT: 0239  // CHECK-NEXT: 1240  // CHECK-NEXT: 0241  // CHECK-NEXT: 0242  // CHECK-NEXT: 1243  // CHECK-NEXT: 0244  // CHECK-NEXT: 1245  // CHECK-NEXT: 0246  // CHECK-NEXT: 0247  // CHECK-NEXT: 0248  func.call @check_cmpi_slt(%cst0, %cst0) : (i16, i16) -> ()249  func.call @check_cmpi_slt(%cst0, %cst1) : (i16, i16) -> ()250  func.call @check_cmpi_slt(%cst1, %cst0) : (i16, i16) -> ()251  func.call @check_cmpi_slt(%cst1, %cst1) : (i16, i16) -> ()252  func.call @check_cmpi_slt(%cst_n1, %cst1) : (i16, i16) -> ()253  func.call @check_cmpi_slt(%cst1, %cst_n1) : (i16, i16) -> ()254  func.call @check_cmpi_slt(%cst_n1, %cst1337) : (i16, i16) -> ()255  func.call @check_cmpi_slt(%cst1337, %cst1337) : (i16, i16) -> ()256  func.call @check_cmpi_slt(%cst4096, %cst4096) : (i16, i16) -> ()257  func.call @check_cmpi_slt(%cst1337, %cst_i16_min) : (i16, i16) -> ()258 259  // CHECK-NEXT: 1260  // CHECK-NEXT: 0261  // CHECK-NEXT: 1262  // CHECK-NEXT: 1263  // CHECK-NEXT: 1264  // CHECK-NEXT: 0265  // CHECK-NEXT: 1266  // CHECK-NEXT: 1267  // CHECK-NEXT: 1268  // CHECK-NEXT: 0269  func.call @check_cmpi_uge(%cst0, %cst0) : (i16, i16) -> ()270  func.call @check_cmpi_uge(%cst0, %cst1) : (i16, i16) -> ()271  func.call @check_cmpi_uge(%cst1, %cst0) : (i16, i16) -> ()272  func.call @check_cmpi_uge(%cst1, %cst1) : (i16, i16) -> ()273  func.call @check_cmpi_uge(%cst_n1, %cst1) : (i16, i16) -> ()274  func.call @check_cmpi_uge(%cst1, %cst_n1) : (i16, i16) -> ()275  func.call @check_cmpi_uge(%cst_n1, %cst1337) : (i16, i16) -> ()276  func.call @check_cmpi_uge(%cst1337, %cst1337) : (i16, i16) -> ()277  func.call @check_cmpi_uge(%cst4096, %cst4096) : (i16, i16) -> ()278  func.call @check_cmpi_uge(%cst1337, %cst_i16_min) : (i16, i16) -> ()279 280  // CHECK-NEXT: 0281  // CHECK-NEXT: 0282  // CHECK-NEXT: 1283  // CHECK-NEXT: 0284  // CHECK-NEXT: 1285  // CHECK-NEXT: 0286  // CHECK-NEXT: 1287  // CHECK-NEXT: 0288  // CHECK-NEXT: 0289  // CHECK-NEXT: 0290  func.call @check_cmpi_ugt(%cst0, %cst0) : (i16, i16) -> ()291  func.call @check_cmpi_ugt(%cst0, %cst1) : (i16, i16) -> ()292  func.call @check_cmpi_ugt(%cst1, %cst0) : (i16, i16) -> ()293  func.call @check_cmpi_ugt(%cst1, %cst1) : (i16, i16) -> ()294  func.call @check_cmpi_ugt(%cst_n1, %cst1) : (i16, i16) -> ()295  func.call @check_cmpi_ugt(%cst1, %cst_n1) : (i16, i16) -> ()296  func.call @check_cmpi_ugt(%cst_n1, %cst1337) : (i16, i16) -> ()297  func.call @check_cmpi_ugt(%cst1337, %cst1337) : (i16, i16) -> ()298  func.call @check_cmpi_ugt(%cst4096, %cst4096) : (i16, i16) -> ()299  func.call @check_cmpi_ugt(%cst1337, %cst_i16_min) : (i16, i16) -> ()300 301  // CHECK-NEXT: 1302  // CHECK-NEXT: 1303  // CHECK-NEXT: 0304  // CHECK-NEXT: 1305  // CHECK-NEXT: 0306  // CHECK-NEXT: 1307  // CHECK-NEXT: 0308  // CHECK-NEXT: 1309  // CHECK-NEXT: 1310  // CHECK-NEXT: 1311  func.call @check_cmpi_ule(%cst0, %cst0) : (i16, i16) -> ()312  func.call @check_cmpi_ule(%cst0, %cst1) : (i16, i16) -> ()313  func.call @check_cmpi_ule(%cst1, %cst0) : (i16, i16) -> ()314  func.call @check_cmpi_ule(%cst1, %cst1) : (i16, i16) -> ()315  func.call @check_cmpi_ule(%cst_n1, %cst1) : (i16, i16) -> ()316  func.call @check_cmpi_ule(%cst1, %cst_n1) : (i16, i16) -> ()317  func.call @check_cmpi_ule(%cst_n1, %cst1337) : (i16, i16) -> ()318  func.call @check_cmpi_ule(%cst1337, %cst1337) : (i16, i16) -> ()319  func.call @check_cmpi_ule(%cst4096, %cst4096) : (i16, i16) -> ()320  func.call @check_cmpi_ule(%cst1337, %cst_i16_min) : (i16, i16) -> ()321 322  // CHECK-NEXT: 0323  // CHECK-NEXT: 1324  // CHECK-NEXT: 0325  // CHECK-NEXT: 0326  // CHECK-NEXT: 0327  // CHECK-NEXT: 1328  // CHECK-NEXT: 0329  // CHECK-NEXT: 0330  // CHECK-NEXT: 0331  // CHECK-NEXT: 1332  func.call @check_cmpi_ult(%cst0, %cst0) : (i16, i16) -> ()333  func.call @check_cmpi_ult(%cst0, %cst1) : (i16, i16) -> ()334  func.call @check_cmpi_ult(%cst1, %cst0) : (i16, i16) -> ()335  func.call @check_cmpi_ult(%cst1, %cst1) : (i16, i16) -> ()336  func.call @check_cmpi_ult(%cst_n1, %cst1) : (i16, i16) -> ()337  func.call @check_cmpi_ult(%cst1, %cst_n1) : (i16, i16) -> ()338  func.call @check_cmpi_ult(%cst_n1, %cst1337) : (i16, i16) -> ()339  func.call @check_cmpi_ult(%cst1337, %cst1337) : (i16, i16) -> ()340  func.call @check_cmpi_ult(%cst4096, %cst4096) : (i16, i16) -> ()341  func.call @check_cmpi_ult(%cst1337, %cst_i16_min) : (i16, i16) -> ()342 343  return344}345