1 // RUN: mlir-opt -lower-affine --split-input-file %s | FileCheck %s
3 // CHECK-LABEL: func @affine_vector_load
4 func.func @affine_vector_load(%arg0 : index) {
5 %0 = memref.alloc() : memref<100xf32>
6 affine.for %i0 = 0 to 16 {
7 %1 = affine.vector_load %0[%i0 + symbol(%arg0) + 7] : memref<100xf32>, vector<8xf32>
9 // CHECK: %[[buf:.*]] = memref.alloc
10 // CHECK: %[[a:.*]] = arith.addi %{{.*}}, %{{.*}} : index
11 // CHECK-NEXT: %[[c7:.*]] = arith.constant 7 : index
12 // CHECK-NEXT: %[[b:.*]] = arith.addi %[[a]], %[[c7]] : index
13 // CHECK-NEXT: vector.load %[[buf]][%[[b]]] : memref<100xf32>, vector<8xf32>
19 // CHECK-LABEL: func @affine_vector_store
20 func.func @affine_vector_store(%arg0 : index) {
21 %0 = memref.alloc() : memref<100xf32>
22 %1 = arith.constant dense<11.0> : vector<4xf32>
23 affine.for %i0 = 0 to 16 {
24 affine.vector_store %1, %0[%i0 - symbol(%arg0) + 7] : memref<100xf32>, vector<4xf32>
26 // CHECK: %[[buf:.*]] = memref.alloc
27 // CHECK: %[[val:.*]] = arith.constant dense
28 // CHECK: %[[c_1:.*]] = arith.constant -1 : index
29 // CHECK-NEXT: %[[a:.*]] = arith.muli %arg0, %[[c_1]] : index
30 // CHECK-NEXT: %[[b:.*]] = arith.addi %{{.*}}, %[[a]] : index
31 // CHECK-NEXT: %[[c7:.*]] = arith.constant 7 : index
32 // CHECK-NEXT: %[[c:.*]] = arith.addi %[[b]], %[[c7]] : index
33 // CHECK-NEXT: vector.store %[[val]], %[[buf]][%[[c]]] : memref<100xf32>, vector<4xf32>
39 // CHECK-LABEL: func @vector_load_2d
40 func.func @vector_load_2d() {
41 %0 = memref.alloc() : memref<100x100xf32>
42 affine.for %i0 = 0 to 16 step 2{
43 affine.for %i1 = 0 to 16 step 8 {
44 %1 = affine.vector_load %0[%i0, %i1] : memref<100x100xf32>, vector<2x8xf32>
45 // CHECK: %[[buf:.*]] = memref.alloc
46 // CHECK: scf.for %[[i0:.*]] =
47 // CHECK: scf.for %[[i1:.*]] =
48 // CHECK-NEXT: vector.load %[[buf]][%[[i0]], %[[i1]]] : memref<100x100xf32>, vector<2x8xf32>
56 // CHECK-LABEL: func @vector_store_2d
57 func.func @vector_store_2d() {
58 %0 = memref.alloc() : memref<100x100xf32>
59 %1 = arith.constant dense<11.0> : vector<2x8xf32>
60 affine.for %i0 = 0 to 16 step 2{
61 affine.for %i1 = 0 to 16 step 8 {
62 affine.vector_store %1, %0[%i0, %i1] : memref<100x100xf32>, vector<2x8xf32>
63 // CHECK: %[[buf:.*]] = memref.alloc
64 // CHECK: %[[val:.*]] = arith.constant dense
65 // CHECK: scf.for %[[i0:.*]] =
66 // CHECK: scf.for %[[i1:.*]] =
67 // CHECK-NEXT: vector.store %[[val]], %[[buf]][%[[i0]], %[[i1]]] : memref<100x100xf32>, vector<2x8xf32>