1// RUN: mlir-opt -legalize-std-for-spirv %s -o - | FileCheck %s
2
3module {
4
5//===----------------------------------------------------------------------===//
6// std.subview
7//===----------------------------------------------------------------------===//
8
9// CHECK-LABEL: @fold_static_stride_subview
10// CHECK-SAME: %[[ARG0:[a-zA-Z0-9_]*]]: memref<12x32xf32>
11// CHECK-SAME: %[[ARG1:[a-zA-Z0-9_]*]]: index
12// CHECK-SAME: %[[ARG2:[a-zA-Z0-9_]*]]: index
13// CHECK-SAME: %[[ARG3:[a-zA-Z0-9_]*]]: index
14// CHECK-SAME: %[[ARG4:[a-zA-Z0-9_]*]]: index
15func @fold_static_stride_subview
16       (%arg0 : memref<12x32xf32>, %arg1 : index,
17        %arg2 : index, %arg3 : index, %arg4 : index) {
18  // CHECK-DAG: %[[C2:.*]] = constant 2
19  // CHECK-DAG: %[[C3:.*]] = constant 3
20  //     CHECK: %[[T0:.*]] = muli %[[ARG3]], %[[C3]]
21  //     CHECK: %[[T1:.*]] = addi %[[ARG1]], %[[T0]]
22  //     CHECK: %[[T2:.*]] = muli %[[ARG4]], %[[ARG2]]
23  //     CHECK: %[[T3:.*]] = addi %[[T2]], %[[C2]]
24  //     CHECK: %[[LOADVAL:.*]] = load %[[ARG0]][%[[T1]], %[[T3]]]
25  //     CHECK: %[[STOREVAL:.*]] = sqrt %[[LOADVAL]]
26  //     CHECK: %[[T6:.*]] = muli %[[ARG3]], %[[C3]]
27  //     CHECK: %[[T7:.*]] = addi %[[ARG1]], %[[T6]]
28  //     CHECK: %[[T8:.*]] = muli %[[ARG4]], %[[ARG2]]
29  //     CHECK: %[[T9:.*]] = addi %[[T8]], %[[C2]]
30  //     CHECK: store %[[STOREVAL]], %[[ARG0]][%[[T7]], %[[T9]]]
31  %0 = subview %arg0[%arg1, 2][4, 4][3, %arg2] : memref<12x32xf32> to memref<4x4xf32, offset:?, strides: [96, ?]>
32  %1 = load %0[%arg3, %arg4] : memref<4x4xf32, offset:?, strides: [96, ?]>
33  %2 = sqrt %1 : f32
34  store %2, %0[%arg3, %arg4] : memref<4x4xf32, offset:?, strides: [96, ?]>
35  return
36}
37
38} // end module
39