|
| 1 | +// RUN: mlir-opt -int-range-optimizations --split-input-file %s | FileCheck %s |
| 2 | + |
| 3 | +// CHECK-LABEL: @dim_const |
| 4 | +// CHECK: %[[ret:.+]] = arith.constant 3 : index |
| 5 | +// CHECK: return %[[ret]] |
| 6 | +func.func @dim_const(%m: memref<3x5xi32>) -> index { |
| 7 | + %c0 = arith.constant 0 : index |
| 8 | + %0 = memref.dim %m, %c0 : memref<3x5xi32> |
| 9 | + return %0 : index |
| 10 | +} |
| 11 | + |
| 12 | +// ----- |
| 13 | + |
| 14 | +// CHECK-LABEL: @dim_any_static |
| 15 | +// CHECK: %[[op:.+]] = memref.dim |
| 16 | +// CHECK: %[[ret:.+]] = test.reflect_bounds {smax = 5 : index, smin = 3 : index, umax = 5 : index, umin = 3 : index} %[[op]] |
| 17 | +// CHECK: return %[[ret]] |
| 18 | +func.func @dim_any_static(%m: memref<3x5xi32>, %x: index) -> index { |
| 19 | + %0 = memref.dim %m, %x : memref<3x5xi32> |
| 20 | + %1 = test.reflect_bounds %0 : index |
| 21 | + return %1 : index |
| 22 | +} |
| 23 | + |
| 24 | +// ----- |
| 25 | + |
| 26 | +// CHECK-LABEL: @dim_dynamic |
| 27 | +// CHECK: %[[op:.+]] = memref.dim |
| 28 | +// CHECK: %[[ret:.+]] = test.reflect_bounds {smax = 9223372036854775807 : index, smin = 0 : index, umax = 9223372036854775807 : index, umin = 0 : index} %[[op]] |
| 29 | +// CHECK: return %[[ret]] |
| 30 | +func.func @dim_dynamic(%m: memref<?x5xi32>) -> index { |
| 31 | + %c0 = arith.constant 0 : index |
| 32 | + %0 = memref.dim %m, %c0 : memref<?x5xi32> |
| 33 | + %1 = test.reflect_bounds %0 : index |
| 34 | + return %1 : index |
| 35 | +} |
| 36 | + |
| 37 | +// ----- |
| 38 | + |
| 39 | +// CHECK-LABEL: @dim_any_dynamic |
| 40 | +// CHECK: %[[op:.+]] = memref.dim |
| 41 | +// CHECK: %[[ret:.+]] = test.reflect_bounds {smax = 9223372036854775807 : index, smin = 0 : index, umax = 9223372036854775807 : index, umin = 0 : index} %[[op]] |
| 42 | +// CHECK: return %[[ret]] |
| 43 | +func.func @dim_any_dynamic(%m: memref<?x5xi32>, %x: index) -> index { |
| 44 | + %0 = memref.dim %m, %x : memref<?x5xi32> |
| 45 | + %1 = test.reflect_bounds %0 : index |
| 46 | + return %1 : index |
| 47 | +} |
| 48 | + |
| 49 | +// ----- |
| 50 | + |
| 51 | +// CHECK-LABEL: @dim_some_omitting_dynamic |
| 52 | +// CHECK: %[[op:.+]] = memref.dim |
| 53 | +// CHECK: %[[ret:.+]] = test.reflect_bounds {smax = 5 : index, smin = 3 : index, umax = 5 : index, umin = 3 : index} %[[op]] |
| 54 | +// CHECK: return %[[ret]] |
| 55 | +func.func @dim_some_omitting_dynamic(%m: memref<?x3x5xi32>, %x: index) -> index { |
| 56 | + %c1 = arith.constant 1 : index |
| 57 | + %0 = arith.maxsi %x, %c1 : index |
| 58 | + %1 = memref.dim %m, %0 : memref<?x3x5xi32> |
| 59 | + %2 = test.reflect_bounds %1 : index |
| 60 | + return %2 : index |
| 61 | +} |
| 62 | + |
| 63 | +// ----- |
| 64 | + |
| 65 | +// CHECK-LABEL: @dim_unranked |
| 66 | +// CHECK: %[[op:.+]] = memref.dim |
| 67 | +// CHECK: %[[ret:.+]] = test.reflect_bounds {smax = 9223372036854775807 : index, smin = 0 : index, umax = 9223372036854775807 : index, umin = 0 : index} %[[op]] |
| 68 | +// CHECK: return %[[ret]] |
| 69 | +func.func @dim_unranked(%m: memref<*xi32>) -> index { |
| 70 | + %c0 = arith.constant 0 : index |
| 71 | + %0 = memref.dim %m, %c0 : memref<*xi32> |
| 72 | + %1 = test.reflect_bounds %0 : index |
| 73 | + return %1 : index |
| 74 | +} |
0 commit comments