[Mlir-commits] [mlir] [mlir][arith] adding addition regression tests (PR #96973)

Andrzej WarzyƄski llvmlistbot at llvm.org
Sun Jun 30 08:54:14 PDT 2024


================
@@ -0,0 +1,84 @@
+// Tests arith operations on i1 type.
+// These tests are intended to be target agnostic: they should yield the same results 
+// regardless of the target platform.
+
+// 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 @add_i1(%v1 : i1, %v2 : i1) -> (i1) {
+  %res = arith.addi %v1, %v2 : i1
+  vector.print %res : i1
+  return %res : i1
+}
+
+func.func @additions_i1() {
+  // addi on i1
+  // addi(0, 1) : i1 = 1 : i1; addi(0, -1) : i1 = 1
+  %false = arith.constant 0 : i1
+  %true = arith.constant 1 : i1
+
+  // CHECK:      1
+  %0 = func.call @add_i1(%false, %true) : (i1, i1) -> i1
+
+  // CHECK-NEXT: 1
+  %true_based_on_non_zero_val = arith.constant -1 : i1
+  %1 = func.call @add_i1(%false, %true_based_on_non_zero_val) : (i1, i1) -> i1
+
+  return
+}
+
+func.func @addui_extended_i1(%v1 : i1, %v2 : i1) -> (i1, i1) {
----------------
banach-space wrote:

The return values are never used, are they?

https://github.com/llvm/llvm-project/pull/96973


More information about the Mlir-commits mailing list