1 // RUN: mlir-opt %s -allow-unregistered-dialect \
2 // RUN: --test-transform-dialect-interpreter -verify-diagnostics \
3 // RUN: --split-input-file | FileCheck %s
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]]
9 func.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
16 transform.sequence failures(propagate) {
17 ^bb1(%arg1: !pdl.operation):
18 %0 = transform.structured.match ops{["affine.min", "affine.max"]} in %arg1 : (!pdl.operation) -> !pdl.operation
19 %1 = transform.structured.match ops{["test.some_op"]} in %arg1 : (!pdl.operation) -> !pdl.operation
20 transform.affine.simplify_bounded_affine_ops %0 with [%1] within [0] and [20]
25 // CHECK: func @simplify_min_sequence()
26 // CHECK: %[[c1:.*]] = arith.constant 1 : index
27 // CHECK: return %[[c1]]
28 func.func @simplify_min_sequence() -> index {
29 %1 = "test.workgroup_id"() : () -> (index)
30 %2 = affine.min affine_map<()[s0] -> (s0 * -32 + 1023, 32)>()[%1]
31 %3 = "test.thread_id"() : () -> (index)
32 %4 = affine.min affine_map<()[s0, s1] -> (s0 - s1 * (s0 ceildiv 32), s0 ceildiv 32)>()[%2, %3]
36 transform.sequence failures(propagate) {
37 ^bb1(%arg1: !pdl.operation):
38 %0 = transform.structured.match ops{["affine.min"]} in %arg1 : (!pdl.operation) -> !pdl.operation
39 %1 = transform.structured.match ops{["test.workgroup_id"]} in %arg1 : (!pdl.operation) -> !pdl.operation
40 %2 = transform.structured.match ops{["test.thread_id"]} in %arg1 : (!pdl.operation) -> !pdl.operation
41 transform.affine.simplify_bounded_affine_ops %0 with [%1, %2] within [0, 0] and [31, 31]
46 transform.sequence failures(propagate) {
47 ^bb1(%arg1: !pdl.operation):
48 %0 = transform.structured.match ops{["affine.min"]} in %arg1 : (!pdl.operation) -> !pdl.operation
49 // expected-error@+1 {{incorrect number of lower bounds, expected 0 but found 1}}
50 transform.affine.simplify_bounded_affine_ops %0 with [] within [0] and []
55 transform.sequence failures(propagate) {
56 ^bb1(%arg1: !pdl.operation):
57 %0 = transform.structured.match ops{["affine.min"]} in %arg1 : (!pdl.operation) -> !pdl.operation
58 // expected-error@+1 {{incorrect number of upper bounds, expected 0 but found 1}}
59 transform.affine.simplify_bounded_affine_ops %0 with [] within [] and [5]