150
|
1 // RUN: mlir-opt -legalize-std-for-spirv -verify-diagnostics %s -o - | FileCheck %s
|
|
2
|
|
3 // CHECK-LABEL: @fold_static_stride_subview_with_load
|
|
4 // CHECK-SAME: [[ARG0:%.*]]: memref<12x32xf32>, [[ARG1:%.*]]: index, [[ARG2:%.*]]: index, [[ARG3:%.*]]: index, [[ARG4:%.*]]: index
|
|
5 func @fold_static_stride_subview_with_load(%arg0 : memref<12x32xf32>, %arg1 : index, %arg2 : index, %arg3 : index, %arg4 : index) {
|
|
6 // CHECK-NOT: subview
|
|
7 // CHECK: [[C2:%.*]] = constant 2 : index
|
|
8 // CHECK: [[C3:%.*]] = constant 3 : index
|
|
9 // CHECK: [[STRIDE1:%.*]] = muli [[ARG3]], [[C2]] : index
|
|
10 // CHECK: [[INDEX1:%.*]] = addi [[ARG1]], [[STRIDE1]] : index
|
|
11 // CHECK: [[STRIDE2:%.*]] = muli [[ARG4]], [[C3]] : index
|
|
12 // CHECK: [[INDEX2:%.*]] = addi [[ARG2]], [[STRIDE2]] : index
|
|
13 // CHECK: load [[ARG0]]{{\[}}[[INDEX1]], [[INDEX2]]{{\]}}
|
|
14 %0 = subview %arg0[%arg1, %arg2][][] : memref<12x32xf32> to memref<4x4xf32, offset:?, strides: [64, 3]>
|
|
15 %1 = load %0[%arg3, %arg4] : memref<4x4xf32, offset:?, strides: [64, 3]>
|
|
16 return
|
|
17 }
|
|
18
|
|
19 // CHECK-LABEL: @fold_dynamic_stride_subview_with_load
|
|
20 // CHECK-SAME: [[ARG0:%.*]]: memref<12x32xf32>, [[ARG1:%.*]]: index, [[ARG2:%.*]]: index, [[ARG3:%.*]]: index, [[ARG4:%.*]]: index, [[ARG5:%.*]]: index, [[ARG6:%.*]]: index
|
|
21 func @fold_dynamic_stride_subview_with_load(%arg0 : memref<12x32xf32>, %arg1 : index, %arg2 : index, %arg3 : index, %arg4 : index, %arg5 : index, %arg6 : index) {
|
|
22 // CHECK-NOT: subview
|
|
23 // CHECK: [[STRIDE1:%.*]] = muli [[ARG3]], [[ARG5]] : index
|
|
24 // CHECK: [[INDEX1:%.*]] = addi [[ARG1]], [[STRIDE1]] : index
|
|
25 // CHECK: [[STRIDE2:%.*]] = muli [[ARG4]], [[ARG6]] : index
|
|
26 // CHECK: [[INDEX2:%.*]] = addi [[ARG2]], [[STRIDE2]] : index
|
|
27 // CHECK: load [[ARG0]]{{\[}}[[INDEX1]], [[INDEX2]]{{\]}}
|
|
28 %0 = subview %arg0[%arg1, %arg2][][%arg5, %arg6] : memref<12x32xf32> to memref<4x4xf32, offset:?, strides: [?, ?]>
|
|
29 %1 = load %0[%arg3, %arg4] : memref<4x4xf32, offset:?, strides: [?, ?]>
|
|
30 return
|
|
31 }
|
|
32
|
|
33 // CHECK-LABEL: @fold_static_stride_subview_with_store
|
|
34 // CHECK-SAME: [[ARG0:%.*]]: memref<12x32xf32>, [[ARG1:%.*]]: index, [[ARG2:%.*]]: index, [[ARG3:%.*]]: index, [[ARG4:%.*]]: index, [[ARG5:%.*]]: f32
|
|
35 func @fold_static_stride_subview_with_store(%arg0 : memref<12x32xf32>, %arg1 : index, %arg2 : index, %arg3 : index, %arg4 : index, %arg5 : f32) {
|
|
36 // CHECK-NOT: subview
|
|
37 // CHECK: [[C2:%.*]] = constant 2 : index
|
|
38 // CHECK: [[C3:%.*]] = constant 3 : index
|
|
39 // CHECK: [[STRIDE1:%.*]] = muli [[ARG3]], [[C2]] : index
|
|
40 // CHECK: [[INDEX1:%.*]] = addi [[ARG1]], [[STRIDE1]] : index
|
|
41 // CHECK: [[STRIDE2:%.*]] = muli [[ARG4]], [[C3]] : index
|
|
42 // CHECK: [[INDEX2:%.*]] = addi [[ARG2]], [[STRIDE2]] : index
|
|
43 // CHECK: store [[ARG5]], [[ARG0]]{{\[}}[[INDEX1]], [[INDEX2]]{{\]}}
|
|
44 %0 = subview %arg0[%arg1, %arg2][][] : memref<12x32xf32> to memref<4x4xf32, offset:?, strides: [64, 3]>
|
|
45 store %arg5, %0[%arg3, %arg4] : memref<4x4xf32, offset:?, strides: [64, 3]>
|
|
46 return
|
|
47 }
|
|
48
|
|
49 // CHECK-LABEL: @fold_dynamic_stride_subview_with_store
|
|
50 // CHECK-SAME: [[ARG0:%.*]]: memref<12x32xf32>, [[ARG1:%.*]]: index, [[ARG2:%.*]]: index, [[ARG3:%.*]]: index, [[ARG4:%.*]]: index, [[ARG5:%.*]]: index, [[ARG6:%.*]]: index, [[ARG7:%.*]]: f32
|
|
51 func @fold_dynamic_stride_subview_with_store(%arg0 : memref<12x32xf32>, %arg1 : index, %arg2 : index, %arg3 : index, %arg4 : index, %arg5 : index, %arg6 : index, %arg7 : f32) {
|
|
52 // CHECK-NOT: subview
|
|
53 // CHECK: [[STRIDE1:%.*]] = muli [[ARG3]], [[ARG5]] : index
|
|
54 // CHECK: [[INDEX1:%.*]] = addi [[ARG1]], [[STRIDE1]] : index
|
|
55 // CHECK: [[STRIDE2:%.*]] = muli [[ARG4]], [[ARG6]] : index
|
|
56 // CHECK: [[INDEX2:%.*]] = addi [[ARG2]], [[STRIDE2]] : index
|
|
57 // CHECK: store [[ARG7]], [[ARG0]]{{\[}}[[INDEX1]], [[INDEX2]]{{\]}}
|
|
58 %0 = subview %arg0[%arg1, %arg2][][%arg5, %arg6] : memref<12x32xf32> to memref<4x4xf32, offset:?, strides: [?, ?]>
|
|
59 store %arg7, %0[%arg3, %arg4] : memref<4x4xf32, offset:?, strides: [?, ?]>
|
|
60 return
|
|
61 }
|