1 // RUN: mlir-opt %s -convert-vector-to-scf='lower-permutation-maps=true' -split-input-file | FileCheck %s
3 // Ensure that the permutation map is lowered (by inserting a transpose op)
4 // before lowering the vector.transfer_read.
6 // CHECK-LABEL: func @transfer_read_2d_mask_transposed(
7 // CHECK-DAG: %[[PADDING:.*]] = arith.constant dense<-4.200000e+01> : vector<9xf32>
8 // CHECK-DAG: %[[MASK:.*]] = arith.constant dense<{{.*}}> : vector<9x4xi1>
9 // CHECK: %[[MASK_MEM:.*]] = memref.alloca() : memref<vector<4x9xi1>>
10 // CHECK: %[[MASK_T:.*]] = vector.transpose %[[MASK]], [1, 0] : vector<9x4xi1> to vector<4x9xi1>
11 // CHECK: memref.store %[[MASK_T]], %[[MASK_MEM]][] : memref<vector<4x9xi1>>
12 // CHECK: %[[MASK_CASTED:.*]] = vector.type_cast %[[MASK_MEM]] : memref<vector<4x9xi1>> to memref<4xvector<9xi1>>
13 // CHECK: scf.for {{.*}} {
14 // CHECK: scf.if {{.*}} {
15 // CHECK: %[[MASK_LOADED:.*]] = memref.load %[[MASK_CASTED]][%{{.*}}] : memref<4xvector<9xi1>>
16 // CHECK: %[[READ:.*]] = vector.transfer_read %{{.*}}, %{{.*}}, %[[MASK_LOADED]] : memref<?x?xf32>, vector<9xf32>
17 // CHECK: memref.store %[[READ]], %{{.*}} : memref<4xvector<9xf32>>
20 // CHECK: %[[RESULT:.*]] = memref.load %{{.*}} : memref<vector<4x9xf32>>
21 // CHECK: %[[RESULT_T:.*]] = vector.transpose %[[RESULT]], [1, 0] : vector<4x9xf32> to vector<9x4xf32>
22 // CHECK: return %[[RESULT_T]] : vector<9x4xf32>
24 // Vector load with mask + transpose.
25 func @transfer_read_2d_mask_transposed(
26 %A : memref<?x?xf32>, %base1: index, %base2: index) -> (vector<9x4xf32>) {
27 %fm42 = arith.constant -42.0: f32
28 %mask = arith.constant dense<[[1, 0, 1, 0], [0, 0, 1, 0],
29 [1, 1, 1, 1], [0, 1, 1, 0],
30 [1, 1, 1, 1], [1, 1, 1, 1],
31 [1, 1, 1, 1], [0, 0, 0, 0],
32 [1, 1, 1, 1]]> : vector<9x4xi1>
33 %f = vector.transfer_read %A[%base1, %base2], %fm42, %mask
34 {permutation_map = affine_map<(d0, d1) -> (d1, d0)>} :
35 memref<?x?xf32>, vector<9x4xf32>
36 return %f : vector<9x4xf32>