42 lines · plain
1// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline='builtin.module(func.func(canonicalize{top-down=true}))' | FileCheck %s --check-prefix=TD2// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline='builtin.module(func.func(canonicalize))' | FileCheck %s --check-prefix=BU3 4 5// BU-LABEL: func @default_insertion_position6// TD-LABEL: func @default_insertion_position7func.func @default_insertion_position(%cond: i1) {8 // Constant should be folded into the entry block.9 10 // BU: arith.constant 211 // BU-NEXT: scf.if12 13 // TD: arith.constant 214 // TD-NEXT: scf.if15 scf.if %cond {16 %0 = arith.constant 1 : i3217 %2 = arith.addi %0, %0 : i3218 "foo.yield"(%2) : (i32) -> ()19 }20 return21}22 23// This shows that we don't pull the constant out of the region because it24// wants to be the insertion point for the constant.25// BU-LABEL: func @custom_insertion_position26// TD-LABEL: func @custom_insertion_position27func.func @custom_insertion_position() {28 // BU: test.one_region_op29 // BU-NEXT: arith.constant 230 31 // TD: test.one_region_op32 // TD-NEXT: arith.constant 233 "test.one_region_op"() ({34 35 %0 = arith.constant 1 : i3236 %2 = arith.addi %0, %0 : i3237 "foo.yield"(%2) : (i32) -> ()38 }) : () -> ()39 return40}41 42