[Mlir-commits] [mlir] [mlir][arith] mul operation regressions (PR #96975)

Jacob Yu llvmlistbot at llvm.org
Fri Jun 28 04:27:49 PDT 2024


https://github.com/pingshiyu updated https://github.com/llvm/llvm-project/pull/96975

>From 67998205165c1e733084431ad48ab283dc0e172b Mon Sep 17 00:00:00 2001
From: pingshiyu <pingshiyu at gmail.com>
Date: Thu, 27 Jun 2024 22:58:35 +0100
Subject: [PATCH 1/2] mul regressions

---
 .../Dialect/Arith/CPU/multiplication.mlir     | 44 +++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 mlir/test/Integration/Dialect/Arith/CPU/multiplication.mlir

diff --git a/mlir/test/Integration/Dialect/Arith/CPU/multiplication.mlir b/mlir/test/Integration/Dialect/Arith/CPU/multiplication.mlir
new file mode 100644
index 0000000000000..494bc2af1821e
--- /dev/null
+++ b/mlir/test/Integration/Dialect/Arith/CPU/multiplication.mlir
@@ -0,0 +1,44 @@
+// Tests mul operations and their variants (e.g. extended).
+// 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 @mulsi_extended_on_i1() {
+    // mulsi_extended on i1, tests for overflow bit
+    // mulsi_extended 1, 1 : i1 = (1, 0)
+    // CHECK:      1
+    // CHECK-NEXT: 0
+    %true = arith.constant true
+    %low, %high = arith.mulsi_extended %true, %true : i1
+    vector.print %low : i1
+    vector.print %high : i1
+    return
+}
+
+func.func @mulsi_mului_extended_overflows() {
+    // mulsi and mului extended versions, with overflow
+    // mulsi_extended -100, -100 : i8 = (16, 39); mului_extended -100, -100 : i8 = (16, 95)
+    // CHECK-NEXT:  16
+    // CHECK-NEXT:  39
+    // CHECK-NEXT:  16
+    // CHECK-NEXT:  95
+    %c-100_i8 = arith.constant -100 : i8
+    %low, %high = arith.mulsi_extended %c-100_i8, %c-100_i8 : i8
+    vector.print %low : i8
+    vector.print %high : i8
+    %low_0, %high_1 = arith.mului_extended %c-100_i8, %c-100_i8 : i8
+    vector.print %low_0 : i8
+    vector.print %high_1 : i8
+    return
+}
+
+func.func @entry() {
+    func.call @mulsi_extended_on_i1() : () -> ()
+    func.call @mulsi_mului_extended_overflows() : () -> ()
+    return
+}

>From 3edd5f75273ae4fa347fba49dcf1629e74c1e281 Mon Sep 17 00:00:00 2001
From: pingshiyu <pingshiyu at gmail.com>
Date: Fri, 28 Jun 2024 12:27:40 +0100
Subject: [PATCH 2/2] reindented

---
 .../Dialect/Arith/CPU/multiplication.mlir     | 52 +++++++++----------
 1 file changed, 26 insertions(+), 26 deletions(-)

diff --git a/mlir/test/Integration/Dialect/Arith/CPU/multiplication.mlir b/mlir/test/Integration/Dialect/Arith/CPU/multiplication.mlir
index 494bc2af1821e..c48173db81f92 100644
--- a/mlir/test/Integration/Dialect/Arith/CPU/multiplication.mlir
+++ b/mlir/test/Integration/Dialect/Arith/CPU/multiplication.mlir
@@ -9,36 +9,36 @@
 // RUN:   FileCheck %s --match-full-lines
 
 func.func @mulsi_extended_on_i1() {
-    // mulsi_extended on i1, tests for overflow bit
-    // mulsi_extended 1, 1 : i1 = (1, 0)
-    // CHECK:      1
-    // CHECK-NEXT: 0
-    %true = arith.constant true
-    %low, %high = arith.mulsi_extended %true, %true : i1
-    vector.print %low : i1
-    vector.print %high : i1
-    return
+  // mulsi_extended on i1, tests for overflow bit
+  // mulsi_extended 1, 1 : i1 = (1, 0)
+  // CHECK:      1
+  // CHECK-NEXT: 0
+  %true = arith.constant true
+  %low, %high = arith.mulsi_extended %true, %true : i1
+  vector.print %low : i1
+  vector.print %high : i1
+  return
 }
 
 func.func @mulsi_mului_extended_overflows() {
-    // mulsi and mului extended versions, with overflow
-    // mulsi_extended -100, -100 : i8 = (16, 39); mului_extended -100, -100 : i8 = (16, 95)
-    // CHECK-NEXT:  16
-    // CHECK-NEXT:  39
-    // CHECK-NEXT:  16
-    // CHECK-NEXT:  95
-    %c-100_i8 = arith.constant -100 : i8
-    %low, %high = arith.mulsi_extended %c-100_i8, %c-100_i8 : i8
-    vector.print %low : i8
-    vector.print %high : i8
-    %low_0, %high_1 = arith.mului_extended %c-100_i8, %c-100_i8 : i8
-    vector.print %low_0 : i8
-    vector.print %high_1 : i8
-    return
+  // mulsi and mului extended versions, with overflow
+  // mulsi_extended -100, -100 : i8 = (16, 39); mului_extended -100, -100 : i8 = (16, 95)
+  // CHECK-NEXT:  16
+  // CHECK-NEXT:  39
+  // CHECK-NEXT:  16
+  // CHECK-NEXT:  95
+  %c-100_i8 = arith.constant -100 : i8
+  %low, %high = arith.mulsi_extended %c-100_i8, %c-100_i8 : i8
+  vector.print %low : i8
+  vector.print %high : i8
+  %low_0, %high_1 = arith.mului_extended %c-100_i8, %c-100_i8 : i8
+  vector.print %low_0 : i8
+  vector.print %high_1 : i8
+  return
 }
 
 func.func @entry() {
-    func.call @mulsi_extended_on_i1() : () -> ()
-    func.call @mulsi_mului_extended_overflows() : () -> ()
-    return
+  func.call @mulsi_extended_on_i1() : () -> ()
+  func.call @mulsi_mului_extended_overflows() : () -> ()
+  return
 }



More information about the Mlir-commits mailing list