blob: 46fc4d085ba56520594e321c439ba57439f2cb0a [file] [log] [blame]
rkayaith13bd4102022-10-18 18:44:111// 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
Chris Lattner648f34a2021-05-17 16:51:453
4
5// BU-LABEL: func @default_insertion_position
6// TD-LABEL: func @default_insertion_position
River Riddlecda6aa72022-04-20 23:22:217func.func @default_insertion_position(%cond: i1) {
Chris Lattner648f34a2021-05-17 16:51:458 // Constant should be folded into the entry block.
9
Mogballa54f4ea2021-10-12 23:14:5710 // BU: arith.constant 2
Chris Lattner648f34a2021-05-17 16:51:4511 // BU-NEXT: scf.if
12
Mogballa54f4ea2021-10-12 23:14:5713 // TD: arith.constant 2
Chris Lattner648f34a2021-05-17 16:51:4514 // TD-NEXT: scf.if
15 scf.if %cond {
Mogballa54f4ea2021-10-12 23:14:5716 %0 = arith.constant 1 : i32
17 %2 = arith.addi %0, %0 : i32
Chris Lattner648f34a2021-05-17 16:51:4518 "foo.yield"(%2) : (i32) -> ()
19 }
20 return
21}
22
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
River Riddlecda6aa72022-04-20 23:22:2127func.func @custom_insertion_position() {
Chris Lattner648f34a2021-05-17 16:51:4528 // BU: test.one_region_op
Mogballa54f4ea2021-10-12 23:14:5729 // BU-NEXT: arith.constant 2
Chris Lattner648f34a2021-05-17 16:51:4530
31 // TD: test.one_region_op
Mogballa54f4ea2021-10-12 23:14:5732 // TD-NEXT: arith.constant 2
Chris Lattner648f34a2021-05-17 16:51:4533 "test.one_region_op"() ({
34
Mogballa54f4ea2021-10-12 23:14:5735 %0 = arith.constant 1 : i32
36 %2 = arith.addi %0, %0 : i32
Chris Lattner648f34a2021-05-17 16:51:4537 "foo.yield"(%2) : (i32) -> ()
38 }) : () -> ()
39 return
40}
41