61 lines · plain
1// RUN: mlir-opt -pass-pipeline="builtin.module(func.func(affine-simplify-min-max))" %s | FileCheck %s2 3// CHECK-DAG: #[[MAP_0:.*]] = affine_map<()[s0] -> (32, s0)>4// CHECK-DAG: #[[MAP_1:.*]] = affine_map<()[s0, s1] -> (s1, s0)>5// CHECK-DAG: #[[MAP_2:.*]] = affine_map<()[s0] -> (256, s0)>6 7// CHECK: @min_max_full_simplify8func.func @min_max_full_simplify() -> (index, index) {9 %0 = test.value_with_bounds {max = 128 : index, min = 0 : index}10 %1 = test.value_with_bounds {max = 512 : index, min = 256 : index}11 // CHECK: %[[V0:.*]] = test.value_with_bounds {max = 128 : index, min = 0 : index}12 // CHECK: %[[V1:.*]] = test.value_with_bounds {max = 512 : index, min = 256 : index}13 // CHECK-NOT: affine.min14 // CHECK-NOT: affine.max15 // CHECK: return %[[V0]], %[[V1]]16 %r0 = affine.min affine_map<()[s0, s1] -> (s0, 192, s1)>()[%0, %1]17 %r1 = affine.max affine_map<()[s0, s1] -> (s0, 192, s1)>()[%0, %1]18 return %r0, %r1 : index, index19}20 21// CHECK: @min_only_simplify22func.func @min_only_simplify() -> (index, index) {23 // CHECK: %[[V0:.*]] = test.value_with_bounds {max = 512 : index, min = 0 : index}24 // CHECK: %[[V1:.*]] = test.value_with_bounds {max = 512 : index, min = 256 : index}25 // CHECK: affine.min #[[MAP_0]]()[%[[V0]]]26 // CHECK: affine.max #[[MAP_1]]()[%[[V0]], %[[V1]]]27 %0 = test.value_with_bounds {max = 512 : index, min = 0 : index}28 %1 = test.value_with_bounds {max = 512 : index, min = 256 : index}29 %r0 = affine.min affine_map<()[s0, s1] -> (s0, 32, s1)>()[%0, %1]30 %r1 = affine.max affine_map<()[s0, s1] -> (s0, 32, s1)>()[%0, %1]31 return %r0, %r1 : index, index32}33 34// CHECK: @max_only_simplify35func.func @max_only_simplify() -> (index, index) {36 // CHECK: %[[V0:.*]] = test.value_with_bounds {max = 128 : index, min = 0 : index}37 // CHECK: %[[V1:.*]] = test.value_with_bounds {max = 512 : index, min = 0 : index}38 // CHECK: affine.min #[[MAP_1]]()[%[[V0]], %[[V1]]]39 // CHECK: affine.max #[[MAP_2]]()[%[[V1]]]40 %0 = test.value_with_bounds {max = 128 : index, min = 0 : index}41 %1 = test.value_with_bounds {max = 512 : index, min = 0 : index}42 %r0 = affine.min affine_map<()[s0, s1] -> (s0, 256, s1)>()[%0, %1]43 %r1 = affine.max affine_map<()[s0, s1] -> (s0, 256, s1)>()[%0, %1]44 return %r0, %r1 : index, index45}46 47// CHECK: @overlapping_constraints48func.func @overlapping_constraints() -> (index, index) {49 %0 = test.value_with_bounds {max = 192 : index, min = 0 : index}50 %1 = test.value_with_bounds {max = 384 : index, min = 128 : index}51 %2 = test.value_with_bounds {max = 512 : index, min = 256 : index}52 // CHECK: %[[V0:.*]] = test.value_with_bounds {max = 192 : index, min = 0 : index}53 // CHECK: %[[V1:.*]] = test.value_with_bounds {max = 384 : index, min = 128 : index}54 // CHECK: %[[V2:.*]] = test.value_with_bounds {max = 512 : index, min = 256 : index}55 // CHECK: affine.min #[[MAP_1]]()[%[[V0]], %[[V1]]]56 // CHECK: affine.max #[[MAP_1]]()[%[[V1]], %[[V2]]]57 %r0 = affine.min affine_map<()[s0, s1, s2] -> (s0, s1, s2)>()[%0, %1, %2]58 %r1 = affine.max affine_map<()[s0, s1, s2] -> (s0, s1, s2)>()[%0, %1, %2]59 return %r0, %r1 : index, index60}61