116 lines · plain
1// RUN: mlir-opt -test-make-isolated-from-above=simple -allow-unregistered-dialect --split-input-file %s | FileCheck %s2// RUN: mlir-opt -test-make-isolated-from-above=clone-ops-with-no-operands -allow-unregistered-dialect --split-input-file %s | FileCheck %s --check-prefix=CLONE13// RUN: mlir-opt -test-make-isolated-from-above=clone-ops-with-operands -allow-unregistered-dialect --split-input-file %s | FileCheck %s --check-prefix=CLONE24 5func.func @make_isolated_from_above_single_block(%arg0 : index, %arg1 : index) {6 %c0 = arith.constant 0: index7 %c1 = arith.constant 1 : index8 %empty = tensor.empty(%arg0, %arg1) : tensor<?x?xf32>9 %d0 = tensor.dim %empty, %c0 : tensor<?x?xf32>10 %d1 = tensor.dim %empty, %c1 : tensor<?x?xf32>11 "test.one_region_with_operands_op"() ({12 "foo.yield"(%c0, %c1, %d0, %d1) : (index, index, index, index) -> ()13 }) : () -> ()14 return15}16// CHECK-LABEL: func @make_isolated_from_above_single_block(17// CHECK-SAME: %[[ARG0:[a-zA-Z0-9]+]]: index18// CHECK-SAME: %[[ARG1:[a-zA-Z0-9]+]]: index19// CHECK-DAG: %[[C0:.+]] = arith.constant 0 : index20// CHECK-DAG: %[[C1:.+]] = arith.constant 1 : index21// CHECK-DAG: %[[EMPTY:.+]] = tensor.empty(%[[ARG0]], %[[ARG1]])22// CHECK-DAG: %[[D0:.+]] = tensor.dim %[[EMPTY]], %[[C0]]23// CHECK-DAG: %[[D1:.+]] = tensor.dim %[[EMPTY]], %[[C1]]24// CHECK: test.isolated_one_region_op %[[C0]], %[[C1]], %[[D0]], %[[D1]]25// CHECK-NEXT: ^bb0(%[[B0:[a-zA-Z0-9]+]]: index, %[[B1:[a-zA-Z0-9]+]]: index, %[[B2:[a-zA-Z0-9]+]]: index, %[[B3:[a-zA-Z0-9]+]]: index)26// CHECK: "foo.yield"(%[[B0]], %[[B1]], %[[B2]], %[[B3]])27 28// CLONE1-LABEL: func @make_isolated_from_above_single_block(29// CLONE1-SAME: %[[ARG0:[a-zA-Z0-9]+]]: index30// CLONE1-SAME: %[[ARG1:[a-zA-Z0-9]+]]: index31// CLONE1-DAG: %[[C0:.+]] = arith.constant 0 : index32// CLONE1-DAG: %[[C1:.+]] = arith.constant 1 : index33// CLONE1-DAG: %[[EMPTY:.+]] = tensor.empty(%[[ARG0]], %[[ARG1]])34// CLONE1-DAG: %[[D0:.+]] = tensor.dim %[[EMPTY]], %[[C0]]35// CLONE1-DAG: %[[D1:.+]] = tensor.dim %[[EMPTY]], %[[C1]]36// CLONE1: test.isolated_one_region_op %[[D0]], %[[D1]]37// CLONE1-NEXT: ^bb0(%[[B0:[a-zA-Z0-9]+]]: index, %[[B1:[a-zA-Z0-9]+]]: index)38// CLONE1-DAG: %[[C0_0:.+]] = arith.constant 0 : index39// CLONE1-DAG: %[[C1_0:.+]] = arith.constant 1 : index40// CLONE1: "foo.yield"(%[[C0_0]], %[[C1_0]], %[[B0]], %[[B1]])41 42// CLONE2-LABEL: func @make_isolated_from_above_single_block(43// CLONE2-SAME: %[[ARG0:[a-zA-Z0-9]+]]: index44// CLONE2-SAME: %[[ARG1:[a-zA-Z0-9]+]]: index45// CLONE2: test.isolated_one_region_op %[[ARG0]], %[[ARG1]]46// CLONE2-NEXT: ^bb0(%[[B0:[a-zA-Z0-9]+]]: index, %[[B1:[a-zA-Z0-9]+]]: index)47// CLONE2-DAG: %[[C0:.+]] = arith.constant 0 : index48// CLONE2-DAG: %[[C1:.+]] = arith.constant 1 : index49// CLONE2-DAG: %[[EMPTY:.+]] = tensor.empty(%[[B0]], %[[B1]])50// CLONE2-DAG: %[[D0:.+]] = tensor.dim %[[EMPTY]], %[[C0]]51// CLONE2-DAG: %[[D1:.+]] = tensor.dim %[[EMPTY]], %[[C1]]52// CLONE2: "foo.yield"(%[[C0]], %[[C1]], %[[D0]], %[[D1]])53 54// -----55 56func.func @make_isolated_from_above_multiple_blocks(%arg0 : index, %arg1 : index, %arg2 : index) {57 %c0 = arith.constant 0: index58 %c1 = arith.constant 1 : index59 %empty = tensor.empty(%arg0, %arg1) : tensor<?x?xf32>60 %d0 = tensor.dim %empty, %c0 : tensor<?x?xf32>61 %d1 = tensor.dim %empty, %c1 : tensor<?x?xf32>62 "test.one_region_with_operands_op"(%arg2) ({63 ^bb0(%b0 : index):64 cf.br ^bb1(%b0: index)65 ^bb1(%b1 : index):66 "foo.yield"(%c0, %c1, %d0, %d1, %b1) : (index, index, index, index, index) -> ()67 }) : (index) -> ()68 return69}70// CHECK-LABEL: func @make_isolated_from_above_multiple_blocks(71// CHECK-SAME: %[[ARG0:[a-zA-Z0-9]+]]: index72// CHECK-SAME: %[[ARG1:[a-zA-Z0-9]+]]: index73// CHECK-SAME: %[[ARG2:[a-zA-Z0-9]+]]: index74// CHECK-DAG: %[[C0:.+]] = arith.constant 0 : index75// CHECK-DAG: %[[C1:.+]] = arith.constant 1 : index76// CHECK-DAG: %[[EMPTY:.+]] = tensor.empty(%[[ARG0]], %[[ARG1]])77// CHECK-DAG: %[[D0:.+]] = tensor.dim %[[EMPTY]], %[[C0]]78// CHECK-DAG: %[[D1:.+]] = tensor.dim %[[EMPTY]], %[[C1]]79// CHECK: test.isolated_one_region_op %[[ARG2]], %[[C0]], %[[C1]], %[[D0]], %[[D1]]80// CHECK-NEXT: ^bb0(%[[B0:[a-zA-Z0-9]+]]: index, %[[B1:[a-zA-Z0-9]+]]: index, %[[B2:[a-zA-Z0-9]+]]: index, %[[B3:[a-zA-Z0-9]+]]: index, %[[B4:[a-zA-Z0-9]+]]: index)81// CHECK-NEXT: cf.br ^bb182// CHECK: ^bb1:83// CHECK: "foo.yield"(%[[B1]], %[[B2]], %[[B3]], %[[B4]], %[[B0]])84 85// CLONE1-LABEL: func @make_isolated_from_above_multiple_blocks(86// CLONE1-SAME: %[[ARG0:[a-zA-Z0-9]+]]: index87// CLONE1-SAME: %[[ARG1:[a-zA-Z0-9]+]]: index88// CLONE1-SAME: %[[ARG2:[a-zA-Z0-9]+]]: index89// CLONE1-DAG: %[[C0:.+]] = arith.constant 0 : index90// CLONE1-DAG: %[[C1:.+]] = arith.constant 1 : index91// CLONE1-DAG: %[[EMPTY:.+]] = tensor.empty(%[[ARG0]], %[[ARG1]])92// CLONE1-DAG: %[[D0:.+]] = tensor.dim %[[EMPTY]], %[[C0]]93// CLONE1-DAG: %[[D1:.+]] = tensor.dim %[[EMPTY]], %[[C1]]94// CLONE1: test.isolated_one_region_op %[[ARG2]], %[[D0]], %[[D1]]95// CLONE1-NEXT: ^bb0(%[[B0:[a-zA-Z0-9]+]]: index, %[[B1:[a-zA-Z0-9]+]]: index, %[[B2:[a-zA-Z0-9]+]]: index)96// CLONE1-DAG: %[[C0_0:.+]] = arith.constant 0 : index97// CLONE1-DAG: %[[C1_0:.+]] = arith.constant 1 : index98// CLONE1-NEXT: cf.br ^bb199// CLONE1: ^bb1:100// CLONE1: "foo.yield"(%[[C0_0]], %[[C1_0]], %[[B1]], %[[B2]], %[[B0]])101 102// CLONE2-LABEL: func @make_isolated_from_above_multiple_blocks(103// CLONE2-SAME: %[[ARG0:[a-zA-Z0-9]+]]: index104// CLONE2-SAME: %[[ARG1:[a-zA-Z0-9]+]]: index105// CLONE2-SAME: %[[ARG2:[a-zA-Z0-9]+]]: index106// CLONE2: test.isolated_one_region_op %[[ARG2]], %[[ARG0]], %[[ARG1]]107// CLONE2-NEXT: ^bb0(%[[B0:[a-zA-Z0-9]+]]: index, %[[B1:[a-zA-Z0-9]+]]: index, %[[B2:[a-zA-Z0-9]+]]: index)108// CLONE2-DAG: %[[C0:.+]] = arith.constant 0 : index109// CLONE2-DAG: %[[C1:.+]] = arith.constant 1 : index110// CLONE2-DAG: %[[EMPTY:.+]] = tensor.empty(%[[B1]], %[[B2]])111// CLONE2-DAG: %[[D0:.+]] = tensor.dim %[[EMPTY]], %[[C0]]112// CLONE2-DAG: %[[D1:.+]] = tensor.dim %[[EMPTY]], %[[C1]]113// CLONE2-NEXT: cf.br ^bb1114// CLONE2: ^bb1:115// CLONE2: "foo.yield"(%[[C0]], %[[C1]], %[[D0]], %[[D1]], %[[B0]])116