1// RUN: mlir-opt -allow-unregistered-dialect -split-input-file -test-merge-blocks -verify-diagnostics %s | FileCheck %s 2 3// CHECK-LABEL: @merge_blocks 4func.func @merge_blocks(%arg0: i32, %arg1 : i32) -> () { 5 // CHECK: "test.merge_blocks"() ({ 6 // CHECK-NEXT: "test.return" 7 // CHECK-NEXT: }) 8 // CHECK-NEXT: "test.return" 9 %0:2 = "test.merge_blocks"() ({ 10 ^bb0: 11 "test.br"(%arg0, %arg1)[^bb1] : (i32, i32) -> () 12 ^bb1(%arg3 : i32, %arg4 : i32): 13 "test.return"(%arg3, %arg4) : (i32, i32) -> () 14 }) : () -> (i32, i32) 15 "test.return"(%0#0, %0#1) : (i32, i32) -> () 16} 17 18// ----- 19 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 25func.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}} 31 // CHECK: ^[[BB]] 32 ^bb1(%arg1 : i32): 33 // CHECK: "unregistered.return" 34 "unregistered.return"(%arg1) : (i32) -> () 35 // expected-remark@-1 {{op 'unregistered.return' is not legalizable}} 36 }) : () -> () 37} 38 39// ----- 40 41// CHECK-LABEL: @inline_regions() 42func.func @inline_regions() -> () 43{ 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"() ({ 49 ^bb0: 50 %0 = "test.type_producer"() : () -> i32 51 "test.SingleBlockImplicitTerminator"() ({ 52 ^bb1: 53 "test.type_consumer"(%0) : (i32) -> () 54 "test.finish"() : () -> () 55 }) : () -> () 56 "test.finish"() : () -> () 57 }) : () -> () 58 "test.return"() : () -> () 59} 60