[Mlir-commits] [mlir] [mlir][arith] Add division integration tests (PR #98181)
Jacob Yu
llvmlistbot at llvm.org
Mon Jul 29 05:38:44 PDT 2024
https://github.com/pingshiyu updated https://github.com/llvm/llvm-project/pull/98181
>From bdafb98b00fc86168f5cfd95aa7eb8b4d27ad3d4 Mon Sep 17 00:00:00 2001
From: pingshiyu <pingshiyu at gmail.com>
Date: Tue, 9 Jul 2024 15:15:56 +0100
Subject: [PATCH 1/8] division regressions added
---
.../Integration/Dialect/Arith/CPU/divide.mlir | 109 ++++++++++++++++++
1 file changed, 109 insertions(+)
create mode 100644 mlir/test/Integration/Dialect/Arith/CPU/divide.mlir
diff --git a/mlir/test/Integration/Dialect/Arith/CPU/divide.mlir b/mlir/test/Integration/Dialect/Arith/CPU/divide.mlir
new file mode 100644
index 0000000000000..a08f7975f5968
--- /dev/null
+++ b/mlir/test/Integration/Dialect/Arith/CPU/divide.mlir
@@ -0,0 +1,109 @@
+// Tests division operations and their variants (e.g. ceil/floordiv, rem etc)
+
+// RUN: mlir-opt %s --arith-expand --test-lower-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 @divsi_i8(%v1 : i8, %v2 : i8) {
+ vector.print str "@divsi_i8\n"
+ %0 = arith.divsi %v1, %v2 : i8
+ vector.print %0 : i8
+ return
+}
+
+func.func @divsi_i1(%v1 : i1, %v2 : i1) {
+ vector.print str "@divsi_i1\n"
+ %0 = arith.divsi %v1, %v2 : i1
+ vector.print %0 : i1
+ return
+
+}
+
+func.func @remsi_i8(%v1 : i8, %v2 : i8) {
+ vector.print str "@remsi_i8\n"
+ %0 = arith.remsi %v1, %v2 : i8
+ vector.print %0 : i8
+ return
+}
+
+func.func @ceildivsi_i8(%v1 : i8, %v2 : i8) {
+ vector.print str "@ceildivsi_i8\n"
+ %0 = arith.ceildivsi %v1, %v2 : i8
+ vector.print %0 : i8
+ return
+}
+
+func.func @divsi() {
+ // ------------------------------------------------
+ // Test i8
+ // ------------------------------------------------
+ %c68 = arith.constant 68 : i8
+ %cn97 = arith.constant -97 : i8
+
+ // divsi should round towards zero (rather than -infinity)
+ // divsi -97 68 = -1
+ // CHECK-LABEL: @divsi_i8
+ // CHECK-NEXT: -1
+ func.call @divsi_i8(%cn97, %c68) : (i8, i8) -> ()
+
+ // ------------------------------------------------
+ // Test i1
+ // ------------------------------------------------
+ %false = arith.constant false
+ %true = arith.constant true
+
+ // CHECK-LABEL: @divsi_i1
+ // CHECK-NEXT: 1
+ func.call @divsi_i1(%true, %true) : (i1, i1) -> ()
+
+ // ------------------------------------------------
+ // TODO: i16, i32 etc
+ // ------------------------------------------------
+ return
+}
+
+func.func @remsi() {
+ // ------------------------------------------------
+ // Test i8
+ // ------------------------------------------------
+ %cn1 = arith.constant -1 : i8
+ %i8_min_p1 = arith.constant -127 : i8
+
+ // remsi minIntPlus1 -1 = remsi -2^(w-1) -1 = 0
+ // CHECK-LABEL: @remsi_i8
+ // CHECK-NEXT: 0
+ func.call @remsi_i8(%i8_min_p1, %cn1) : (i8, i8) -> ()
+
+ // ------------------------------------------------
+ // TODO: i1, i16 etc
+ // ------------------------------------------------
+ return
+}
+
+func.func @ceildivsi() {
+ // ------------------------------------------------
+ // Test i8
+ // ------------------------------------------------
+ %c7 = arith.constant 7 : i8
+ %i8_min = arith.constant -128 : i8
+
+ // ceildivsi should keep signs
+ // forall w, y. (w > 0, y > 0) => -2^w `ceildiv` y : i_w < 0
+ // CHECK-LABEL: @ceildivsi_i8
+ // CHECK-NEXT: -18
+ func.call @ceildivsi_i8(%i8_min, %c7) : (i8, i8) -> ()
+
+ // ------------------------------------------------
+ // TODO: i1, i16 etc
+ // ------------------------------------------------
+
+ return
+}
+
+func.func @entry() {
+ func.call @divsi() : () -> ()
+ func.call @remsi() : () -> ()
+ func.call @ceildivsi() : () -> ()
+ return
+}
>From 730c0e900e0f551c7d5dbbaa68440fefa8e0bf24 Mon Sep 17 00:00:00 2001
From: pingshiyu <pingshiyu at gmail.com>
Date: Thu, 11 Jul 2024 17:10:53 +0100
Subject: [PATCH 2/8] reindented
---
.../Integration/Dialect/Arith/CPU/divide.mlir | 157 +++++++++---------
1 file changed, 78 insertions(+), 79 deletions(-)
diff --git a/mlir/test/Integration/Dialect/Arith/CPU/divide.mlir b/mlir/test/Integration/Dialect/Arith/CPU/divide.mlir
index a08f7975f5968..7c0092e3be581 100644
--- a/mlir/test/Integration/Dialect/Arith/CPU/divide.mlir
+++ b/mlir/test/Integration/Dialect/Arith/CPU/divide.mlir
@@ -6,104 +6,103 @@
// RUN: FileCheck %s --match-full-lines
func.func @divsi_i8(%v1 : i8, %v2 : i8) {
- vector.print str "@divsi_i8\n"
- %0 = arith.divsi %v1, %v2 : i8
- vector.print %0 : i8
- return
+ vector.print str "@divsi_i8\n"
+ %0 = arith.divsi %v1, %v2 : i8
+ vector.print %0 : i8
+ return
}
func.func @divsi_i1(%v1 : i1, %v2 : i1) {
- vector.print str "@divsi_i1\n"
- %0 = arith.divsi %v1, %v2 : i1
- vector.print %0 : i1
- return
-
+ vector.print str "@divsi_i1\n"
+ %0 = arith.divsi %v1, %v2 : i1
+ vector.print %0 : i1
+ return
}
func.func @remsi_i8(%v1 : i8, %v2 : i8) {
- vector.print str "@remsi_i8\n"
- %0 = arith.remsi %v1, %v2 : i8
- vector.print %0 : i8
- return
+ vector.print str "@remsi_i8\n"
+ %0 = arith.remsi %v1, %v2 : i8
+ vector.print %0 : i8
+ return
}
func.func @ceildivsi_i8(%v1 : i8, %v2 : i8) {
- vector.print str "@ceildivsi_i8\n"
- %0 = arith.ceildivsi %v1, %v2 : i8
- vector.print %0 : i8
- return
+ vector.print str "@ceildivsi_i8\n"
+ %0 = arith.ceildivsi %v1, %v2 : i8
+ vector.print %0 : i8
+ return
}
func.func @divsi() {
- // ------------------------------------------------
- // Test i8
- // ------------------------------------------------
- %c68 = arith.constant 68 : i8
- %cn97 = arith.constant -97 : i8
-
- // divsi should round towards zero (rather than -infinity)
- // divsi -97 68 = -1
- // CHECK-LABEL: @divsi_i8
- // CHECK-NEXT: -1
- func.call @divsi_i8(%cn97, %c68) : (i8, i8) -> ()
-
- // ------------------------------------------------
- // Test i1
- // ------------------------------------------------
- %false = arith.constant false
- %true = arith.constant true
-
- // CHECK-LABEL: @divsi_i1
- // CHECK-NEXT: 1
- func.call @divsi_i1(%true, %true) : (i1, i1) -> ()
-
- // ------------------------------------------------
- // TODO: i16, i32 etc
- // ------------------------------------------------
- return
+ // ------------------------------------------------
+ // Test i8
+ // ------------------------------------------------
+ %c68 = arith.constant 68 : i8
+ %cn97 = arith.constant -97 : i8
+
+ // divsi should round towards zero (rather than -infinity)
+ // divsi -97 68 = -1
+ // CHECK-LABEL: @divsi_i8
+ // CHECK-NEXT: -1
+ func.call @divsi_i8(%cn97, %c68) : (i8, i8) -> ()
+
+ // ------------------------------------------------
+ // Test i1
+ // ------------------------------------------------
+ %false = arith.constant false
+ %true = arith.constant true
+
+ // CHECK-LABEL: @divsi_i1
+ // CHECK-NEXT: 1
+ func.call @divsi_i1(%true, %true) : (i1, i1) -> ()
+
+ // ------------------------------------------------
+ // TODO: i16, i32 etc
+ // ------------------------------------------------
+ return
}
func.func @remsi() {
- // ------------------------------------------------
- // Test i8
- // ------------------------------------------------
- %cn1 = arith.constant -1 : i8
- %i8_min_p1 = arith.constant -127 : i8
-
- // remsi minIntPlus1 -1 = remsi -2^(w-1) -1 = 0
- // CHECK-LABEL: @remsi_i8
- // CHECK-NEXT: 0
- func.call @remsi_i8(%i8_min_p1, %cn1) : (i8, i8) -> ()
-
- // ------------------------------------------------
- // TODO: i1, i16 etc
- // ------------------------------------------------
- return
+ // ------------------------------------------------
+ // Test i8
+ // ------------------------------------------------
+ %cn1 = arith.constant -1 : i8
+ %i8_min_p1 = arith.constant -127 : i8
+
+ // remsi minIntPlus1 -1 = remsi -2^(w-1) -1 = 0
+ // CHECK-LABEL: @remsi_i8
+ // CHECK-NEXT: 0
+ func.call @remsi_i8(%i8_min_p1, %cn1) : (i8, i8) -> ()
+
+ // ------------------------------------------------
+ // TODO: i1, i16 etc
+ // ------------------------------------------------
+ return
}
func.func @ceildivsi() {
- // ------------------------------------------------
- // Test i8
- // ------------------------------------------------
- %c7 = arith.constant 7 : i8
- %i8_min = arith.constant -128 : i8
-
- // ceildivsi should keep signs
- // forall w, y. (w > 0, y > 0) => -2^w `ceildiv` y : i_w < 0
- // CHECK-LABEL: @ceildivsi_i8
- // CHECK-NEXT: -18
- func.call @ceildivsi_i8(%i8_min, %c7) : (i8, i8) -> ()
-
- // ------------------------------------------------
- // TODO: i1, i16 etc
- // ------------------------------------------------
-
- return
+ // ------------------------------------------------
+ // Test i8
+ // ------------------------------------------------
+ %c7 = arith.constant 7 : i8
+ %i8_min = arith.constant -128 : i8
+
+ // ceildivsi should keep signs
+ // forall w, y. (w > 0, y > 0) => -2^w `ceildiv` y : i_w < 0
+ // CHECK-LABEL: @ceildivsi_i8
+ // CHECK-NEXT: -18
+ func.call @ceildivsi_i8(%i8_min, %c7) : (i8, i8) -> ()
+
+ // ------------------------------------------------
+ // TODO: i1, i16 etc
+ // ------------------------------------------------
+
+ return
}
func.func @entry() {
- func.call @divsi() : () -> ()
- func.call @remsi() : () -> ()
- func.call @ceildivsi() : () -> ()
- return
+ func.call @divsi() : () -> ()
+ func.call @remsi() : () -> ()
+ func.call @ceildivsi() : () -> ()
+ return
}
>From 4bc154ef0a43118febe9c39638873560f5ef1089 Mon Sep 17 00:00:00 2001
From: pingshiyu <pingshiyu at gmail.com>
Date: Tue, 23 Jul 2024 14:19:34 +0100
Subject: [PATCH 3/8] added some edge cases
---
.../Integration/Dialect/Arith/CPU/divide.mlir | 52 +++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/mlir/test/Integration/Dialect/Arith/CPU/divide.mlir b/mlir/test/Integration/Dialect/Arith/CPU/divide.mlir
index 7c0092e3be581..ca7ed86e4605c 100644
--- a/mlir/test/Integration/Dialect/Arith/CPU/divide.mlir
+++ b/mlir/test/Integration/Dialect/Arith/CPU/divide.mlir
@@ -39,6 +39,8 @@ func.func @divsi() {
// ------------------------------------------------
%c68 = arith.constant 68 : i8
%cn97 = arith.constant -97 : i8
+ %c0 = arith.constant 0 : i8
+ %c1 = arith.constant 1 : i8
// divsi should round towards zero (rather than -infinity)
// divsi -97 68 = -1
@@ -46,6 +48,21 @@ func.func @divsi() {
// CHECK-NEXT: -1
func.call @divsi_i8(%cn97, %c68) : (i8, i8) -> ()
+ // divsi x x == 1
+ // CHECK-LABEL: @divsi_i8
+ // CHECK-NEXT: 1
+ func.call @divsi_i8(%c68, %c68) : (i8, i8) -> ()
+
+ // divsi x 1 == x
+ // CHECK-LABEL: @divsi_i8
+ // CHECK-NEXT: -97
+ func.call @divsi_i8(%cn97, %c1) : (i8, i8) -> ()
+
+ // divsi 0 x == 0
+ // CHECK-LABEL: @divsi_i8
+ // CHECK-NEXT: 0
+ func.call @divsi_i8(%c0, %cn97) : (i8, i8) -> ()
+
// ------------------------------------------------
// Test i1
// ------------------------------------------------
@@ -56,6 +73,10 @@ func.func @divsi() {
// CHECK-NEXT: 1
func.call @divsi_i1(%true, %true) : (i1, i1) -> ()
+ // CHECK-LABEL: @divsi_i1
+ // CHECK-NEXT: 0
+ func.call @divsi_i1(%false, %true) : (i1, i1) -> ()
+
// ------------------------------------------------
// TODO: i16, i32 etc
// ------------------------------------------------
@@ -68,12 +89,25 @@ func.func @remsi() {
// ------------------------------------------------
%cn1 = arith.constant -1 : i8
%i8_min_p1 = arith.constant -127 : i8
+ %i8_min = arith.constant -128 : i8
+ %c0 = arith.constant 0 : i8
+ %c1 = arith.constant 1 : i8
// remsi minIntPlus1 -1 = remsi -2^(w-1) -1 = 0
// CHECK-LABEL: @remsi_i8
// CHECK-NEXT: 0
func.call @remsi_i8(%i8_min_p1, %cn1) : (i8, i8) -> ()
+ // remsi 0 minInt == 0
+ // CHECK-LABEL: @remsi_i8
+ // CHECK-NEXT: 0
+ func.call @remsi_i8(%c0, %i8_min_p1) : (i8, i8) -> ()
+
+ // forall x. remsi x 1 == 0
+ // CHECK-LABEL: @remsi_i8
+ // CHECK-NEXT: 0
+ func.call @remsi_i8(%c0, %c1) : (i8, i8) -> ()
+
// ------------------------------------------------
// TODO: i1, i16 etc
// ------------------------------------------------
@@ -86,6 +120,9 @@ func.func @ceildivsi() {
// ------------------------------------------------
%c7 = arith.constant 7 : i8
%i8_min = arith.constant -128 : i8
+ %c0 = arith.constant 0 : i8
+ %c1 = arith.constant 1 : i8
+ %cn1 = arith.constant -1 : i8
// ceildivsi should keep signs
// forall w, y. (w > 0, y > 0) => -2^w `ceildiv` y : i_w < 0
@@ -93,6 +130,21 @@ func.func @ceildivsi() {
// CHECK-NEXT: -18
func.call @ceildivsi_i8(%i8_min, %c7) : (i8, i8) -> ()
+ // forall x. x / -1 == -x
+ // CHECK-LABEL: @ceildivsi_i8
+ // CHECK-NEXT: -1
+ func.call @ceildivsi_i8(%c1, %cn1) : (i8, i8) -> ()
+
+ // forall x. x / 1 == x
+ // CHECK-LABEL: @ceildivsi_i8
+ // CHECK-NEXT: 1
+ func.call @ceildivsi_i8(%c1, %c1) : (i8, i8) -> ()
+
+ // 0 / x == 0
+ // CHECK-LABEL: @ceildivsi_i8
+ // CHECK-NEXT: 0
+ func.call @ceildivsi_i8(%c0, %c1) : (i8, i8) -> ()
+
// ------------------------------------------------
// TODO: i1, i16 etc
// ------------------------------------------------
>From 3752870d2df45adf1ce42ee6e47708f10923ea18 Mon Sep 17 00:00:00 2001
From: pingshiyu <pingshiyu at gmail.com>
Date: Mon, 29 Jul 2024 00:47:43 +0100
Subject: [PATCH 4/8] addressed comments and added more cases
---
.../Integration/Dialect/Arith/CPU/divide.mlir | 35 ++++++++++++++++---
1 file changed, 30 insertions(+), 5 deletions(-)
diff --git a/mlir/test/Integration/Dialect/Arith/CPU/divide.mlir b/mlir/test/Integration/Dialect/Arith/CPU/divide.mlir
index ca7ed86e4605c..bfbb1e060e096 100644
--- a/mlir/test/Integration/Dialect/Arith/CPU/divide.mlir
+++ b/mlir/test/Integration/Dialect/Arith/CPU/divide.mlir
@@ -88,16 +88,24 @@ func.func @remsi() {
// Test i8
// ------------------------------------------------
%cn1 = arith.constant -1 : i8
+ %c2 = arith.constant 2 : i8
%i8_min_p1 = arith.constant -127 : i8
%i8_min = arith.constant -128 : i8
%c0 = arith.constant 0 : i8
%c1 = arith.constant 1 : i8
- // remsi minIntPlus1 -1 = remsi -2^(w-1) -1 = 0
+ // remsi minIntPlus1 -1 == 0
+ // however remsi -2^(w-1) -1 would be UB according to
+ // LLVM semantics
// CHECK-LABEL: @remsi_i8
// CHECK-NEXT: 0
func.call @remsi_i8(%i8_min_p1, %cn1) : (i8, i8) -> ()
+ // remsi minInt 1 == 0
+ // CHECK-LABEL: @remsi_i8
+ // CHECK-NEXT: 0
+ func.call @remsi_i8(%i8_min, %c1) : (i8, i8) -> ()
+
// remsi 0 minInt == 0
// CHECK-LABEL: @remsi_i8
// CHECK-NEXT: 0
@@ -108,6 +116,11 @@ func.func @remsi() {
// CHECK-NEXT: 0
func.call @remsi_i8(%c0, %c1) : (i8, i8) -> ()
+ // remsi -127 2 == -1
+ // CHECK-LABEL: @remsi_i8
+ // CHECK-NEXT: -1
+ func.call @remsi_i8(%i8_min_p1, %c2) : (i8, i8) -> ()
+
// ------------------------------------------------
// TODO: i1, i16 etc
// ------------------------------------------------
@@ -119,32 +132,44 @@ func.func @ceildivsi() {
// Test i8
// ------------------------------------------------
%c7 = arith.constant 7 : i8
+ %c3 = arith.constant 3 : i8
+ %cn3 = arith.constant -3 : i8
%i8_min = arith.constant -128 : i8
%c0 = arith.constant 0 : i8
%c1 = arith.constant 1 : i8
%cn1 = arith.constant -1 : i8
// ceildivsi should keep signs
- // forall w, y. (w > 0, y > 0) => -2^w `ceildiv` y : i_w < 0
+ // forall w, y. (w > 0, y > 0) => ceildiv (-2^w) y <= 0
// CHECK-LABEL: @ceildivsi_i8
// CHECK-NEXT: -18
func.call @ceildivsi_i8(%i8_min, %c7) : (i8, i8) -> ()
- // forall x. x / -1 == -x
+ // forall x. ceildivsi x -1 == -x
// CHECK-LABEL: @ceildivsi_i8
// CHECK-NEXT: -1
func.call @ceildivsi_i8(%c1, %cn1) : (i8, i8) -> ()
- // forall x. x / 1 == x
+ // forall x. ceildivsi x 1 == x
// CHECK-LABEL: @ceildivsi_i8
// CHECK-NEXT: 1
func.call @ceildivsi_i8(%c1, %c1) : (i8, i8) -> ()
- // 0 / x == 0
+ // ceildivsi 0 x == 0
// CHECK-LABEL: @ceildivsi_i8
// CHECK-NEXT: 0
func.call @ceildivsi_i8(%c0, %c1) : (i8, i8) -> ()
+ // ceildivsi 7 3 == 3 (2.3333 round towards +inf)
+ // CHECK-LABEL: @ceildivsi_i8
+ // CHECK-NEXT: 3
+ func.call @ceildivsi_i8(%c7, %c3) : (i8, i8) -> ()
+
+ // ceildivsi 7 -3 == -1 (-2.3333 round towards +inf)
+ // CHECK-LABEL: @ceildivsi_i8
+ // CHECK-NEXT: -2
+ func.call @ceildivsi_i8(%c7, %cn3) : (i8, i8) -> ()
+
// ------------------------------------------------
// TODO: i1, i16 etc
// ------------------------------------------------
>From cc53710056f5f2302b2a5a2ef097e5672b30da3a Mon Sep 17 00:00:00 2001
From: pingshiyu <pingshiyu at gmail.com>
Date: Mon, 29 Jul 2024 00:52:42 +0100
Subject: [PATCH 5/8] comment on i1
---
mlir/test/Integration/Dialect/Arith/CPU/divide.mlir | 3 +++
1 file changed, 3 insertions(+)
diff --git a/mlir/test/Integration/Dialect/Arith/CPU/divide.mlir b/mlir/test/Integration/Dialect/Arith/CPU/divide.mlir
index bfbb1e060e096..d5cf790a4e62c 100644
--- a/mlir/test/Integration/Dialect/Arith/CPU/divide.mlir
+++ b/mlir/test/Integration/Dialect/Arith/CPU/divide.mlir
@@ -49,6 +49,9 @@ func.func @divsi() {
func.call @divsi_i8(%cn97, %c68) : (i8, i8) -> ()
// divsi x x == 1
+ // note that i1 (booleans) are printed as:
+ // false/true -> 0/1
+ // rather than as 0/-1
// CHECK-LABEL: @divsi_i8
// CHECK-NEXT: 1
func.call @divsi_i8(%c68, %c68) : (i8, i8) -> ()
>From 7717315cc68eb430e897cfbedf497f736c71ef8c Mon Sep 17 00:00:00 2001
From: Jacob Yu <pingshiyu at gmail.com>
Date: Mon, 29 Jul 2024 13:26:32 +0100
Subject: [PATCH 6/8] Update
mlir/test/Integration/Dialect/Arith/CPU/divide.mlir
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-authored-by: Andrzej Warzyński <andrzej.warzynski at gmail.com>
---
mlir/test/Integration/Dialect/Arith/CPU/divide.mlir | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mlir/test/Integration/Dialect/Arith/CPU/divide.mlir b/mlir/test/Integration/Dialect/Arith/CPU/divide.mlir
index d5cf790a4e62c..86b1f785e41e0 100644
--- a/mlir/test/Integration/Dialect/Arith/CPU/divide.mlir
+++ b/mlir/test/Integration/Dialect/Arith/CPU/divide.mlir
@@ -98,8 +98,8 @@ func.func @remsi() {
%c1 = arith.constant 1 : i8
// remsi minIntPlus1 -1 == 0
- // however remsi -2^(w-1) -1 would be UB according to
- // LLVM semantics
+ // However, remsi -2^(w-1) -1 would be UB according to
+ // LLVM semantics.
// CHECK-LABEL: @remsi_i8
// CHECK-NEXT: 0
func.call @remsi_i8(%i8_min_p1, %cn1) : (i8, i8) -> ()
>From 5242eab3138b19e2af7b4f0080e0bd9875628407 Mon Sep 17 00:00:00 2001
From: Jacob Yu <pingshiyu at gmail.com>
Date: Mon, 29 Jul 2024 13:26:43 +0100
Subject: [PATCH 7/8] Update
mlir/test/Integration/Dialect/Arith/CPU/divide.mlir
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-authored-by: Andrzej Warzyński <andrzej.warzynski at gmail.com>
---
mlir/test/Integration/Dialect/Arith/CPU/divide.mlir | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mlir/test/Integration/Dialect/Arith/CPU/divide.mlir b/mlir/test/Integration/Dialect/Arith/CPU/divide.mlir
index 86b1f785e41e0..0d9a4d6ce2df0 100644
--- a/mlir/test/Integration/Dialect/Arith/CPU/divide.mlir
+++ b/mlir/test/Integration/Dialect/Arith/CPU/divide.mlir
@@ -49,7 +49,7 @@ func.func @divsi() {
func.call @divsi_i8(%cn97, %c68) : (i8, i8) -> ()
// divsi x x == 1
- // note that i1 (booleans) are printed as:
+ // Note that i1 (booleans) are printed as:
// false/true -> 0/1
// rather than as 0/-1
// CHECK-LABEL: @divsi_i8
>From 5e26295c460bbb05ac8b079bab14b380cffdcf54 Mon Sep 17 00:00:00 2001
From: pingshiyu <pingshiyu at gmail.com>
Date: Mon, 29 Jul 2024 13:38:27 +0100
Subject: [PATCH 8/8] comments on i1/bool printing
---
.../Integration/Dialect/Arith/CPU/divide.mlir | 39 +++++++++++--------
1 file changed, 22 insertions(+), 17 deletions(-)
diff --git a/mlir/test/Integration/Dialect/Arith/CPU/divide.mlir b/mlir/test/Integration/Dialect/Arith/CPU/divide.mlir
index 0d9a4d6ce2df0..e1e3ebdfa8bdb 100644
--- a/mlir/test/Integration/Dialect/Arith/CPU/divide.mlir
+++ b/mlir/test/Integration/Dialect/Arith/CPU/divide.mlir
@@ -34,6 +34,28 @@ func.func @ceildivsi_i8(%v1 : i8, %v2 : i8) {
}
func.func @divsi() {
+ // ------------------------------------------------
+ // Test i1
+ // ------------------------------------------------
+
+ // Note that i1 (booleans) are printed as:
+ // false/true -> 0/1
+ // rather than as 0/-1
+ // this is because they are automatically zero-extended
+ // by the --convert-verctor-to-llvm pass (called as a part
+ // of --test-lower-to-llvm pass)
+
+ %false = arith.constant false
+ %true = arith.constant true
+
+ // CHECK-LABEL: @divsi_i1
+ // CHECK-NEXT: 1
+ func.call @divsi_i1(%true, %true) : (i1, i1) -> ()
+
+ // CHECK-LABEL: @divsi_i1
+ // CHECK-NEXT: 0
+ func.call @divsi_i1(%false, %true) : (i1, i1) -> ()
+
// ------------------------------------------------
// Test i8
// ------------------------------------------------
@@ -49,9 +71,6 @@ func.func @divsi() {
func.call @divsi_i8(%cn97, %c68) : (i8, i8) -> ()
// divsi x x == 1
- // Note that i1 (booleans) are printed as:
- // false/true -> 0/1
- // rather than as 0/-1
// CHECK-LABEL: @divsi_i8
// CHECK-NEXT: 1
func.call @divsi_i8(%c68, %c68) : (i8, i8) -> ()
@@ -66,20 +85,6 @@ func.func @divsi() {
// CHECK-NEXT: 0
func.call @divsi_i8(%c0, %cn97) : (i8, i8) -> ()
- // ------------------------------------------------
- // Test i1
- // ------------------------------------------------
- %false = arith.constant false
- %true = arith.constant true
-
- // CHECK-LABEL: @divsi_i1
- // CHECK-NEXT: 1
- func.call @divsi_i1(%true, %true) : (i1, i1) -> ()
-
- // CHECK-LABEL: @divsi_i1
- // CHECK-NEXT: 0
- func.call @divsi_i1(%false, %true) : (i1, i1) -> ()
-
// ------------------------------------------------
// TODO: i16, i32 etc
// ------------------------------------------------
More information about the Mlir-commits
mailing list