[Mlir-commits] [mlir] [mlir][Vector] Add `vector.shuffle` tree transformation (PR #145740)
Andrzej WarzyĆski
llvmlistbot at llvm.org
Tue Jul 8 08:55:48 PDT 2025
================
@@ -0,0 +1,423 @@
+// RUN: mlir-opt -lower-vector-to-from-elements-to-shuffle-tree -split-input-file %s | FileCheck %s
+
+// Captured variable names for `vector.shuffle` operations follow the L#SH# convention,
+// where L# refers to the level of the tree the shuffle belongs to, and SH# refers to
+// the shuffle index within that level.
+
+func.func @trivial_forwarding(%a: vector<8xf32>) -> vector<8xf32> {
+ %0:8 = vector.to_elements %a : vector<8xf32>
+ %1 = vector.from_elements %0#0, %0#1, %0#2, %0#3, %0#4, %0#5, %0#6, %0#7 : vector<8xf32>
+ return %1 : vector<8xf32>
+}
+
+// No shuffle tree needed for trivial forwarding case.
+
+// CHECK-LABEL: func @trivial_forwarding(
+// CHECK-SAME: %[[A:.*]]: vector<8xf32>
+// CHECK: return %[[A]] : vector<8xf32>
+
+// -----
+
+func.func @unsupported_multi_dim_vector_inputs(%a: vector<2x4xf32>, %b: vector<2x4xf32>) -> vector<4xf32> {
+ %0:8 = vector.to_elements %a : vector<2x4xf32>
+ %1:8 = vector.to_elements %b : vector<2x4xf32>
+ %2 = vector.from_elements %0#0, %0#7,
+ %1#0, %1#7 : vector<4xf32>
+ return %2 : vector<4xf32>
+}
+
+// -----
+
+func.func @unsupported_multi_dim_vector_output(%a: vector<8xf32>, %b: vector<8xf32>) -> vector<2x2xf32> {
+ %0:8 = vector.to_elements %a : vector<8xf32>
+ %1:8 = vector.to_elements %b : vector<8xf32>
+ %2 = vector.from_elements %0#0, %0#7,
+ %1#0, %1#7 : vector<2x2xf32>
+ return %2 : vector<2x2xf32>
----------------
banach-space wrote:
Missing `CHECK` lines
https://github.com/llvm/llvm-project/pull/145740
More information about the Mlir-commits
mailing list