1 // RUN: mlir-opt -allow-unregistered-dialect -split-input-file -test-merge-blocks -verify-diagnostics %s | FileCheck %s
3 // CHECK-LABEL: @merge_blocks
4 func.func @merge_blocks(%arg0: i32, %arg1 : i32) -> () {
5 // CHECK: "test.merge_blocks"() ({
6 // CHECK-NEXT: "test.return"
8 // CHECK-NEXT: "test.return"
9 %0:2 = "test.merge_blocks"() ({
11 "test.br"(%arg0, %arg1)[^bb1] : (i32, i32) -> ()
12 ^bb1(%arg3 : i32, %arg4 : i32):
13 "test.return"(%arg3, %arg4) : (i32, i32) -> ()
15 "test.return"(%0#0, %0#1) : (i32, i32) -> ()
20 // The op in this function is rewritten to itself (and thus remains
21 // illegal) by a pattern that merges the second block with the first
22 // after adding an operation into it. Check that we can undo block
23 // removal successfully.
24 // CHECK-LABEL: @undo_blocks_merge
25 func.func @undo_blocks_merge(%arg0: i32) {
26 "test.undo_blocks_merge"() ({
27 // expected-remark@-1 {{op 'test.undo_blocks_merge' is not legalizable}}
28 // CHECK: "unregistered.return"(%{{.*}})[^[[BB:.*]]]
29 "unregistered.return"(%arg0)[^bb1] : (i32) -> ()
30 // expected-remark@-1 {{op 'unregistered.return' is not legalizable}}
33 // CHECK: "unregistered.return"
34 "unregistered.return"(%arg1) : (i32) -> ()
35 // expected-remark@-1 {{op 'unregistered.return' is not legalizable}}
41 // CHECK-LABEL: @inline_regions()
42 func.func @inline_regions() -> ()
44 // CHECK: test.SingleBlockImplicitTerminator
45 // CHECK-NEXT: %[[T0:.*]] = "test.type_producer"
46 // CHECK-NEXT: "test.type_consumer"(%[[T0]])
47 // CHECK-NEXT: "test.finish"
48 "test.SingleBlockImplicitTerminator"() ({
50 %0 = "test.type_producer"() : () -> i32
51 "test.SingleBlockImplicitTerminator"() ({
53 "test.type_consumer"(%0) : (i32) -> ()
54 "test.finish"() : () -> ()
56 "test.finish"() : () -> ()
58 "test.return"() : () -> ()