[Mlir-commits] [mlir] 66a2058 - [mlir][arith] Adding addition regression tests (#96973)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Jul 8 12:31:01 PDT 2024


Author: Jacob Yu
Date: 2024-07-08T15:30:57-04:00
New Revision: 66a2058e76db120e61c9b34e40bc244d3a6a86fb

URL: https://github.com/llvm/llvm-project/commit/66a2058e76db120e61c9b34e40bc244d3a6a86fb
DIFF: https://github.com/llvm/llvm-project/commit/66a2058e76db120e61c9b34e40bc244d3a6a86fb.diff

LOG: [mlir][arith] Adding addition regression tests (#96973)

arith addition regression tests, a component of the large
https://github.com/llvm/llvm-project/pull/92272

Added: 
    mlir/test/Integration/Dialect/Arith/CPU/addition.mlir

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/mlir/test/Integration/Dialect/Arith/CPU/addition.mlir b/mlir/test/Integration/Dialect/Arith/CPU/addition.mlir
new file mode 100644
index 00000000000000..b6acfd53c1f5d9
--- /dev/null
+++ b/mlir/test/Integration/Dialect/Arith/CPU/addition.mlir
@@ -0,0 +1,88 @@
+// 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 @addi_i1(%v1 : i1, %v2 : i1) {
+  vector.print str "@addi_i1\n"
+  %res = arith.addi %v1, %v2 : i1
+  vector.print %res : i1
+  return
+}
+
+func.func @addi() {
+  // ------------------------------------------------
+  // Test 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-LABEL: @addi_i1
+  // CHECK-NEXT:  1
+  func.call @addi_i1(%false, %true) : (i1, i1) -> ()
+
+  // CHECK-LABEL: @addi_i1
+  // CHECK-NEXT:  1
+  %true_based_on_non_zero_val = arith.constant -1 : i1
+  func.call @addi_i1(%false, %true_based_on_non_zero_val) : (i1, i1) -> ()
+
+  // ------------------------------------------------
+  // TODO: Test i8, i16 etc..
+  // ------------------------------------------------
+
+  return
+}
+
+func.func @addui_extended_i1(%v1 : i1, %v2 : i1) {
+  vector.print str "@addui_extended_i1\n"
+  %res, %overflow = arith.addui_extended %v1, %v2 : i1, i1
+  vector.print %res : i1
+  vector.print %overflow : i1
+  return
+}
+
+func.func @addi_extended() {
+  // ------------------------------------------------
+  // Test i1
+  // ------------------------------------------------
+
+  // addui_extended on i1
+  // addui_extended 1 1 : i1 = 0, 1
+  %true = arith.constant 1 : i1
+  %false = arith.constant 0 : i1
+  
+  // CHECK-LABEL: @addui_extended_i1
+  // CHECK-NEXT:  0
+  // CHECK-NEXT:  1
+  func.call @addui_extended_i1(%true, %true) : (i1, i1) -> ()
+
+  // CHECK-LABEL: @addui_extended_i1
+  // CHECK-NEXT:  1
+  // CHECK-NEXT:  0
+  func.call @addui_extended_i1(%true, %false) : (i1, i1) -> ()
+
+  // CHECK-LABEL: @addui_extended_i1
+  // CHECK-NEXT:  1
+  // CHECK-NEXT:  0
+  func.call @addui_extended_i1(%false, %true) : (i1, i1) -> ()
+
+  // CHECK-LABEL: @addui_extended_i1
+  // CHECK-NEXT:  0
+  // CHECK-NEXT:  0
+  func.call @addui_extended_i1(%false, %false) : (i1, i1) -> ()
+
+  // ------------------------------------------------
+  // TODO: Test i8, i16 etc.. 
+  // ------------------------------------------------
+  return
+}
+
+func.func @entry() {
+  func.call @addi() : () -> ()
+  func.call @addi_extended() : () -> ()
+  return
+}


        


More information about the Mlir-commits mailing list