1// RUN: mlir-opt %s -allow-unregistered-dialect \ 2// RUN: --transform-interpreter -verify-diagnostics \ 3// RUN: --split-input-file | FileCheck %s 4 5// CHECK: func @simplify_min_max() 6// CHECK-DAG: %[[c50:.*]] = arith.constant 50 : index 7// CHECK-DAG: %[[c100:.*]] = arith.constant 100 : index 8// CHECK: return %[[c50]], %[[c100]] 9func.func @simplify_min_max() -> (index, index) { 10 %0 = "test.some_op"() : () -> (index) 11 %1 = affine.min affine_map<()[s0] -> (50, 100 - s0)>()[%0] 12 %2 = affine.max affine_map<()[s0] -> (100, 80 + s0)>()[%0] 13 return %1, %2 : index, index 14} 15 16module attributes {transform.with_named_sequence} { 17 transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) { 18 %0 = transform.structured.match ops{["affine.min", "affine.max"]} in %arg1 : (!transform.any_op) -> !transform.any_op 19 %1 = transform.structured.match ops{["test.some_op"]} in %arg1 : (!transform.any_op) -> !transform.any_op 20 transform.affine.simplify_bounded_affine_ops %0 with [%1 : !transform.any_op] within [0] and [20] : !transform.any_op 21 transform.yield 22 } 23} 24 25// ----- 26 27// CHECK: func @simplify_min_sequence() 28// CHECK: %[[c1:.*]] = arith.constant 1 : index 29// CHECK: return %[[c1]] 30func.func @simplify_min_sequence() -> index { 31 %1 = "test.workgroup_id"() : () -> (index) 32 %2 = affine.min affine_map<()[s0] -> (s0 * -32 + 1023, 32)>()[%1] 33 %3 = "test.thread_id"() : () -> (index) 34 %4 = affine.min affine_map<()[s0, s1] -> (s0 - s1 * (s0 ceildiv 32), s0 ceildiv 32)>()[%2, %3] 35 return %4 : index 36} 37 38module attributes {transform.with_named_sequence} { 39 transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) { 40 %0 = transform.structured.match ops{["affine.min"]} in %arg1 : (!transform.any_op) -> !transform.any_op 41 %1 = transform.structured.match ops{["test.workgroup_id"]} in %arg1 : (!transform.any_op) -> !transform.any_op 42 %2 = transform.structured.match ops{["test.thread_id"]} in %arg1 : (!transform.any_op) -> !transform.any_op 43 transform.affine.simplify_bounded_affine_ops %0 with [%1, %2 : !transform.any_op, !transform.any_op] within [0, 0] and [31, 31] : !transform.any_op 44 transform.yield 45 } 46} 47 48// ----- 49 50module attributes {transform.with_named_sequence} { 51 transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) { 52 %0 = transform.structured.match ops{["affine.min"]} in %arg1 : (!transform.any_op) -> !transform.any_op 53 // expected-error@+1 {{incorrect number of lower bounds, expected 0 but found 1}} 54 transform.affine.simplify_bounded_affine_ops %0 with [] within [0] and [] : !transform.any_op 55 transform.yield 56 } 57} 58 59// ----- 60 61module attributes {transform.with_named_sequence} { 62 transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) { 63 %0 = transform.structured.match ops{["affine.min"]} in %arg1 : (!transform.any_op) -> !transform.any_op 64 // expected-error@+1 {{incorrect number of upper bounds, expected 0 but found 1}} 65 transform.affine.simplify_bounded_affine_ops %0 with [] within [] and [5] : !transform.any_op 66 transform.yield 67 } 68} 69