[Mlir-commits] [mlir] [MLIR][Vector] Add unrolling support for bitcast, interleave, and deinterleave ops (PR #194513)
Andrzej WarzyĆski
llvmlistbot at llvm.org
Tue Apr 28 04:56:05 PDT 2026
================
@@ -667,3 +667,75 @@ func.func @shape_cast_with_all_unit_target_shape(%v: vector<2xf32>) -> vector<2x
// CHECK: %[[SC1:.*]] = vector.shape_cast %[[S1]] : vector<1xf32> to vector<1x1xf32>
// CHECK: %[[I1:.*]] = vector.insert_strided_slice %[[SC1]], %[[I0]] {offsets = [1, 0], strides = [1, 1]} : vector<1x1xf32> into vector<2x1xf32>
// CHECK: return %[[I1]] : vector<2x1xf32>
+
+// -----
+
+// Test BitCastOp unrolling - target shape [4, 4]
+func.func @bitcast_unroll(%arg0: vector<8x4xf32>) -> vector<8x8xi16> {
+ %0 = vector.bitcast %arg0 : vector<8x4xf32> to vector<8x8xi16>
+ return %0 : vector<8x8xi16>
+}
+// CHECK-LABEL: func @bitcast_unroll
+// CHECK-SAME: (%[[ARG:.*]]: vector<8x4xf32>) -> vector<8x8xi16>
+// CHECK: %[[INIT:.*]] = arith.constant dense<0> : vector<8x8xi16>
+// CHECK: %[[S0:.*]] = vector.extract_strided_slice %[[ARG]] {offsets = [0, 0], sizes = [4, 2], strides = [1, 1]} : vector<8x4xf32> to vector<4x2xf32>
+// CHECK: %[[BC0:.*]] = vector.bitcast %[[S0]] : vector<4x2xf32> to vector<4x4xi16>
+// CHECK: %[[I0:.*]] = vector.insert_strided_slice %[[BC0]], %[[INIT]] {offsets = [0, 0], strides = [1, 1]} : vector<4x4xi16> into vector<8x8xi16>
----------------
banach-space wrote:
Could you label separate logical blocks like this? It will make reviewing easier.
```suggestion
/// SLICE 0:
// CHECK: %[[INIT:.*]] = arith.constant dense<0> : vector<8x8xi16>
// CHECK: %[[S0:.*]] = vector.extract_strided_slice %[[ARG]] {offsets = [0, 0], sizes = [4, 2], strides = [1, 1]} : vector<8x4xf32> to vector<4x2xf32>
// CHECK: %[[BC0:.*]] = vector.bitcast %[[S0]] : vector<4x2xf32> to vector<4x4xi16>
// CHECK: %[[I0:.*]] = vector.insert_strided_slice %[[BC0]], %[[INIT]] {offsets = [0, 0], strides = [1, 1]} : vector<4x4xi16> into vector<8x8xi16>
//
// SLICE 1:
```
https://github.com/llvm/llvm-project/pull/194513
More information about the Mlir-commits
mailing list