1 // RUN: mlir-opt -allow-unregistered-dialect -mlir-elide-elementsattrs-if-larger=2 -view-op-graph %s -o %t 2>&1 | FileCheck -check-prefix=DFG %s
2 // RUN: mlir-opt -allow-unregistered-dialect -mlir-elide-elementsattrs-if-larger=2 -view-op-graph='print-data-flow-edges=false print-control-flow-edges=true' %s -o %t 2>&1 | FileCheck -check-prefix=CFG %s
4 // DFG-LABEL: digraph G {
5 // DFG: subgraph {{.*}} {
6 // DFG: subgraph {{.*}}
7 // DFG: label = "func.func{{.*}}merge_blocks
8 // DFG: subgraph {{.*}} {
9 // DFG: v[[ARG0:.*]] [label = "arg0"
10 // DFG: v[[CONST10:.*]] [{{.*}}label ={{.*}}10 : i32
11 // DFG: subgraph [[CLUSTER_MERGE_BLOCKS:.*]] {
12 // DFG: v[[ANCHOR:.*]] [label = " ", shape = plain]
13 // DFG: label = "test.merge_blocks
14 // DFG: subgraph {{.*}} {
15 // DFG: v[[TEST_BR:.*]] [{{.*}}label = "test.br
17 // DFG: subgraph {{.*}} {
20 // DFG: v[[TEST_RET:.*]] [{{.*}}label = "test.return
21 // DFG: v[[ARG0]] -> v[[TEST_BR]]
22 // DFG: v[[CONST10]] -> v[[TEST_BR]]
23 // DFG: v[[ANCHOR]] -> v[[TEST_RET]] [ltail = [[CLUSTER_MERGE_BLOCKS]], style = solid];
24 // DFG: v[[ANCHOR]] -> v[[TEST_RET]] [ltail = [[CLUSTER_MERGE_BLOCKS]], style = solid];
26 // CFG-LABEL: digraph G {
27 // CFG: subgraph {{.*}} {
28 // CFG: subgraph {{.*}}
29 // CFG: label = "func.func{{.*}}merge_blocks
30 // CFG: subgraph {{.*}} {
31 // CFG: v[[C1:.*]] [{{.*}}label = "arith.constant
32 // CFG: v[[C2:.*]] [{{.*}}label = "arith.constant
33 // CFG: v[[C3:.*]] [{{.*}}label = "arith.constant
34 // CFG: v[[C4:.*]] [{{.*}}label = "arith.constant
35 // CFG: v[[TEST_FUNC:.*]] [{{.*}}label = "test.func
36 // CFG: subgraph [[CLUSTER_MERGE_BLOCKS:.*]] {
37 // CFG: v[[ANCHOR:.*]] [label = " ", shape = plain]
38 // CFG: label = "test.merge_blocks
39 // CFG: subgraph {{.*}} {
40 // CFG: v[[TEST_BR:.*]] [{{.*}}label = "test.br
42 // CFG: subgraph {{.*}} {
45 // CFG: v[[TEST_RET:.*]] [{{.*}}label = "test.return
46 // CFG: v[[C1]] -> v[[C2]]
47 // CFG: v[[C2]] -> v[[C3]]
48 // CFG: v[[C3]] -> v[[C4]]
49 // CFG: v[[C4]] -> v[[TEST_FUNC]]
50 // CFG: v[[TEST_FUNC]] -> v[[ANCHOR]] [lhead = [[CLUSTER_MERGE_BLOCKS]], style = dashed];
51 // CFG: v[[ANCHOR]] -> v[[TEST_RET]] [ltail = [[CLUSTER_MERGE_BLOCKS]], style = dashed];
53 func.func @merge_blocks(%arg0: i32, %arg1 : i32) -> () {
54 %0 = arith.constant dense<[[0, 1], [2, 3]]> : tensor<2x2xi32>
55 %1 = arith.constant dense<1> : tensor<5xi32>
56 %2 = arith.constant dense<[[0, 1]]> : tensor<1x2xi32>
57 %a = arith.constant 10 : i32
58 %b = "test.func"() : () -> i32
59 %3:2 = "test.merge_blocks"() ({
61 "test.br"(%arg0, %b, %a)[^bb1] : (i32, i32, i32) -> ()
62 ^bb1(%arg3 : i32, %arg4 : i32, %arg5: i32):
63 "test.return"(%arg3, %arg4) : (i32, i32) -> ()
65 "test.return"(%3#0, %3#1) : (i32, i32) -> ()