inlining.mlir
1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// RUN: mlir-opt -allow-unregistered-dialect %s -inline="disable-simplify" | FileCheck %s
// Basic test that functions within affine operations are inlined.
func @func_with_affine_ops(%N: index) {
%c = constant 200 : index
affine.for %i = 1 to 10 {
affine.if affine_set<(i)[N] : (i - 2 >= 0, 4 - i >= 0)>(%i)[%c] {
%w = affine.apply affine_map<(d0,d1)[s0] -> (d0+d1+s0)> (%i, %i) [%N]
}
}
return
}
// CHECK-LABEL: func @inline_with_affine_ops
func @inline_with_affine_ops() {
%c = constant 1 : index
// CHECK: affine.for
// CHECK-NEXT: affine.if
// CHECK-NEXT: affine.apply
// CHECK-NOT: call
call @func_with_affine_ops(%c) : (index) -> ()
return
}
// CHECK-LABEL: func @not_inline_in_affine_op
func @not_inline_in_affine_op() {
%c = constant 1 : index
// CHECK-NOT: affine.if
// CHECK: call
affine.for %i = 1 to 10 {
call @func_with_affine_ops(%c) : (index) -> ()
}
return
}
// -----
// Test when an invalid operation is nested in an affine op.
func @func_with_invalid_nested_op() {
affine.for %i = 1 to 10 {
"foo.opaque"() : () -> ()
}
return
}
// CHECK-LABEL: func @not_inline_invalid_nest_op
func @not_inline_invalid_nest_op() {
// CHECK: call @func_with_invalid_nested_op
call @func_with_invalid_nested_op() : () -> ()
return
}
// -----
// Test that calls are not inlined into affine structures.
func @func_noop() {
return
}
// CHECK-LABEL: func @not_inline_into_affine_ops
func @not_inline_into_affine_ops() {
// CHECK: call @func_noop
affine.for %i = 1 to 10 {
call @func_noop() : () -> ()
}
return
}