1 // RUN: mlir-opt -allow-unregistered-dialect -test-scf-if-utils -split-input-file %s | FileCheck %s
5 // CHECK: func @outlined_then0(%{{.*}}: i1, %{{.*}}: memref<?xf32>) -> i8 {
6 // CHECK-NEXT: %{{.*}} = "some_op"(%{{.*}}, %{{.*}}) : (i1, memref<?xf32>) -> i8
7 // CHECK-NEXT: return %{{.*}} : i8
9 // CHECK: func @outlined_else0(%{{.*}}: i8) -> i8 {
10 // CHECK-NEXT: return %{{.*}}0 : i8
12 // CHECK: func @outline_if_else(
13 // CHECK-NEXT: %{{.*}} = scf.if %{{.*}} -> (i8) {
14 // CHECK-NEXT: %{{.*}} = func.call @outlined_then0(%{{.*}}, %{{.*}}) : (i1, memref<?xf32>) -> i8
15 // CHECK-NEXT: scf.yield %{{.*}} : i8
16 // CHECK-NEXT: } else {
17 // CHECK-NEXT: %{{.*}} = func.call @outlined_else0(%{{.*}}) : (i8) -> i8
18 // CHECK-NEXT: scf.yield %{{.*}} : i8
22 func.func @outline_if_else(%cond: i1, %a: index, %b: memref<?xf32>, %c: i8) {
23 %r = scf.if %cond -> (i8) {
24 %r = "some_op"(%cond, %b) : (i1, memref<?xf32>) -> (i8)
34 // CHECK: func @outlined_then0(%{{.*}}: i1, %{{.*}}: memref<?xf32>) {
35 // CHECK-NEXT: "some_op"(%{{.*}}, %{{.*}}) : (i1, memref<?xf32>) -> ()
38 // CHECK: func @outline_if(
39 // CHECK-NEXT: scf.if %{{.*}} {
40 // CHECK-NEXT: func.call @outlined_then0(%{{.*}}, %{{.*}}) : (i1, memref<?xf32>) -> ()
44 func.func @outline_if(%cond: i1, %a: index, %b: memref<?xf32>, %c: i8) {
46 "some_op"(%cond, %b) : (i1, memref<?xf32>) -> ()
54 // CHECK: func @outlined_then0() {
57 // CHECK: func @outlined_else0(%{{.*}}: i1, %{{.*}}: memref<?xf32>) {
58 // CHECK-NEXT: "some_op"(%{{.*}}, %{{.*}}) : (i1, memref<?xf32>) -> ()
61 // CHECK: func @outline_empty_if_else(
62 // CHECK-NEXT: scf.if %{{.*}} {
63 // CHECK-NEXT: func.call @outlined_then0() : () -> ()
64 // CHECK-NEXT: } else {
65 // CHECK-NEXT: func.call @outlined_else0(%{{.*}}, %{{.*}}) : (i1, memref<?xf32>) -> ()
69 func.func @outline_empty_if_else(%cond: i1, %a: index, %b: memref<?xf32>, %c: i8) {
72 "some_op"(%cond, %b) : (i1, memref<?xf32>) -> ()