[Mlir-commits] [mlir] [mlir][vector] Separate bitwidth specific tests out (PR #138071)

James Newling llvmlistbot at llvm.org
Thu May 1 09:11:13 PDT 2025


================
@@ -0,0 +1,56 @@
+// RUN: mlir-opt %s -split-input-file -test-bit-width-constrained-vector-linearize=target-vector-bitwidth=128 | FileCheck %s --check-prefixes=ALL,BW-128
+// RUN: mlir-opt %s -split-input-file -test-bit-width-constrained-vector-linearize=target-vector-bitwidth=0   | FileCheck %s --check-prefixes=ALL,BW-0
+
+// A vector<2x2xf32> has inner-most dimension with 64-bits. Check that at
+// bitwidth threshold 128 (>= 64), operations are linearized, and at
+// bitwidth threshold 0 (< 64), operations are not linearized.
+
+// ALL-LABEL: test_result_bitwidth_64
+func.func @test_result_bitwidth_64(%arg0: vector<2x2xf32>) -> vector<2x2xf32> {
+
+  // BW-128:   arith.constant {{.*}} vector<4xf32>
+  // BW-0:     arith.constant {{.*}}  vector<2x2xf32>
+  %0 = arith.constant dense<[[1.0, 2.0], [3.0, 4.0]]> : vector<2x2xf32>
+
+  // BW-128: math.sin {{.*}} vector<4xf32>
+  // BW-0:  math.sin {{.*}}  vector<2x2xf32>
+  %1 = math.sin %arg0 : vector<2x2xf32>
+
+  return %0 : vector<2x2xf32>
+}
+
+// -----
+
+// Test that operations with vectors of index type are not linearized.
----------------
newling wrote:

In https://github.com/llvm/llvm-project/pull/136581 I left the comment ["The width of the type 'index' is unbounded (and therefore potentially above the target width)."](https://github.com/llvm/llvm-project/blob/927cdd2c73590ef6475f7e00ce79078d6e8323bd/mlir/test/lib/Dialect/Vector/TestVectorTransforms.cpp#L875). But accurately saying that it is "platform dependent" might be more accurate? 

Source of truth: https://github.com/llvm/llvm-project/blob/0e9740ea1783ceaf8686b13ab7bf9278f34aef6a/mlir/include/mlir/IR/BuiltinTypes.td#L479

I'll add this note to the test before commiting 

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


More information about the Mlir-commits mailing list