1 // RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline='builtin.module(func.func(canonicalize{top-down=true}))' | FileCheck %s --check-prefix=TD
2 // RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline='builtin.module(func.func(canonicalize))' | FileCheck %s --check-prefix=BU
5 // BU-LABEL: func @default_insertion_position
6 // TD-LABEL: func @default_insertion_position
7 func.func @default_insertion_position(%cond: i1) {
8 // Constant should be folded into the entry block.
10 // BU: arith.constant 2
13 // TD: arith.constant 2
16 %0 = arith.constant 1 : i32
17 %2 = arith.addi %0, %0 : i32
18 "foo.yield"(%2) : (i32) -> ()
23 // This shows that we don't pull the constant out of the region because it
24 // wants to be the insertion point for the constant.
25 // BU-LABEL: func @custom_insertion_position
26 // TD-LABEL: func @custom_insertion_position
27 func.func @custom_insertion_position() {
28 // BU: test.one_region_op
29 // BU-NEXT: arith.constant 2
31 // TD: test.one_region_op
32 // TD-NEXT: arith.constant 2
33 "test.one_region_op"() ({
35 %0 = arith.constant 1 : i32
36 %2 = arith.addi %0, %0 : i32
37 "foo.yield"(%2) : (i32) -> ()