[Mlir-commits] [mlir] [mlir][arith] Add comparison regression tests (PR #96974)
Andrzej WarzyĆski
llvmlistbot at llvm.org
Sun Jul 21 08:17:30 PDT 2024
================
@@ -0,0 +1,123 @@
+// RUN: mlir-opt %s --convert-scf-to-cf --convert-cf-to-llvm --convert-vector-to-llvm \
+// RUN: --convert-func-to-llvm --convert-arith-to-llvm | \
+// RUN: mlir-cpu-runner -e entry -entry-point-result=void \
+// RUN: --shared-libs=%mlir_c_runner_utils | \
+// RUN: FileCheck %s --match-full-lines
+
+func.func @cmpi_eq_i1(%v1 : i1, %v2 : i1) {
+ vector.print str "@cmpi_eq_i1\n"
+ %res = arith.cmpi eq, %v1, %v2 : i1
+ vector.print %res : i1
+ return
+}
+
+func.func @cmpi_slt_i1(%v1 : i1, %v2 : i1) {
+ vector.print str "@cmpi_slt_i1\n"
+ %res = arith.cmpi slt, %v1, %v2 : i1
+ vector.print %res : i1
+ return
+}
+
+func.func @cmpi_sle_i1(%v1 : i1, %v2 : i1) {
+ vector.print str "@cmpi_sle_i1\n"
+ %res = arith.cmpi sle, %v1, %v2 : i1
+ vector.print %res : i1
+ return
+}
+
+func.func @cmpi_sgt_i1(%v1 : i1, %v2 : i1) {
+ vector.print str "@cmpi_sgt_i1\n"
+ %res = arith.cmpi sgt, %v1, %v2 : i1
+ vector.print %res : i1
+ return
+}
+
+func.func @cmpi_sge_i1(%v1 : i1, %v2 : i1) {
+ vector.print str "@cmpi_sge_i1\n"
+ %res = arith.cmpi sge, %v1, %v2 : i1
+ vector.print %res : i1
+ return
+}
+
+func.func @cmpi_signed() {
+ // ------------------------------------------------
+ // Test i1
+ // ------------------------------------------------
+ %false_i1 = arith.constant 0 : i1
+ %true_i1 = arith.constant 1 : i1
+ %true_i1_n1 = arith.constant -1 : i1
+
+ // int values 1 and -1 represent the same bitvector
+ // CHECK-LABEL: @cmpi_eq_i1
+ // CHECK-NEXT: 1
+ func.call @cmpi_eq_i1(%true_i1, %true_i1_n1) : (i1, i1) -> ()
----------------
banach-space wrote:
This doesn't quite fit under `@cmpi_signed()`. I'd create another one, `@cmpi_eq`, and also compare `%true_i1` and `%false_i1` (to make sure that it's indeed "0").
https://github.com/llvm/llvm-project/pull/96974
More information about the Mlir-commits
mailing list