|
| 1 | +// RUN: mlir-opt -int-range-optimizations -canonicalize %s | FileCheck %s |
| 2 | + |
| 3 | + |
| 4 | +// CHECK-LABEL: func @constant_vec |
| 5 | +// CHECK: test.reflect_bounds {smax = 7 : index, smin = 0 : index, umax = 7 : index, umin = 0 : index} |
| 6 | +func.func @constant_vec() -> vector<8xindex> { |
| 7 | + %0 = arith.constant dense<[0, 1, 2, 3, 4, 5, 6, 7]> : vector<8xindex> |
| 8 | + %1 = test.reflect_bounds %0 : vector<8xindex> |
| 9 | + func.return %1 : vector<8xindex> |
| 10 | +} |
| 11 | + |
| 12 | +// CHECK-LABEL: func @constant_splat |
| 13 | +// CHECK: test.reflect_bounds {smax = 3 : si32, smin = 3 : si32, umax = 3 : ui32, umin = 3 : ui32} |
| 14 | +func.func @constant_splat() -> vector<8xi32> { |
| 15 | + %0 = arith.constant dense<3> : vector<8xi32> |
| 16 | + %1 = test.reflect_bounds %0 : vector<8xi32> |
| 17 | + func.return %1 : vector<8xi32> |
| 18 | +} |
| 19 | + |
| 20 | + |
| 21 | +// CHECK-LABEL: func @vector_splat |
| 22 | +// CHECK: test.reflect_bounds {smax = 5 : index, smin = 4 : index, umax = 5 : index, umin = 4 : index} |
| 23 | +func.func @vector_splat() -> vector<4xindex> { |
| 24 | + %0 = test.with_bounds { umin = 4 : index, umax = 5 : index, smin = 4 : index, smax = 5 : index } : index |
| 25 | + %1 = vector.splat %0 : vector<4xindex> |
| 26 | + %2 = test.reflect_bounds %1 : vector<4xindex> |
| 27 | + func.return %2 : vector<4xindex> |
| 28 | +} |
| 29 | + |
| 30 | +// CHECK-LABEL: func @vector_extract |
| 31 | +// CHECK: test.reflect_bounds {smax = 6 : index, smin = 5 : index, umax = 6 : index, umin = 5 : index} |
| 32 | +func.func @vector_extract() -> index { |
| 33 | + %0 = test.with_bounds { umin = 5 : index, umax = 6 : index, smin = 5 : index, smax = 6 : index } : vector<4xindex> |
| 34 | + %1 = vector.extract %0[0] : index from vector<4xindex> |
| 35 | + %2 = test.reflect_bounds %1 : index |
| 36 | + func.return %2 : index |
| 37 | +} |
| 38 | + |
| 39 | +// CHECK-LABEL: func @vector_extractelement |
| 40 | +// CHECK: test.reflect_bounds {smax = 7 : index, smin = 6 : index, umax = 7 : index, umin = 6 : index} |
| 41 | +func.func @vector_extractelement() -> index { |
| 42 | + %c0 = arith.constant 0 : index |
| 43 | + %0 = test.with_bounds { umin = 6 : index, umax = 7 : index, smin = 6 : index, smax = 7 : index } : vector<4xindex> |
| 44 | + %1 = vector.extractelement %0[%c0 : index] : vector<4xindex> |
| 45 | + %2 = test.reflect_bounds %1 : index |
| 46 | + func.return %2 : index |
| 47 | +} |
| 48 | + |
| 49 | +// CHECK-LABEL: func @vector_add |
| 50 | +// CHECK: test.reflect_bounds {smax = 12 : index, smin = 10 : index, umax = 12 : index, umin = 10 : index} |
| 51 | +func.func @vector_add() -> vector<4xindex> { |
| 52 | + %0 = test.with_bounds { umin = 4 : index, umax = 5 : index, smin = 4 : index, smax = 5 : index } : vector<4xindex> |
| 53 | + %1 = test.with_bounds { umin = 6 : index, umax = 7 : index, smin = 6 : index, smax = 7 : index } : vector<4xindex> |
| 54 | + %2 = arith.addi %0, %1 : vector<4xindex> |
| 55 | + %3 = test.reflect_bounds %2 : vector<4xindex> |
| 56 | + func.return %3 : vector<4xindex> |
| 57 | +} |
0 commit comments