annotate mlir/test/Conversion/StandardToSPIRV/legalization.mlir @ 150:1d019706d866

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