llvm-project/mlir/test/Transforms/canonicalize-td.mlir
rkayaith 13bd410962 [mlir][Pass] Include anchor op in -pass-pipeline
In D134622 the printed form of a pass manager is changed to include the
name of the op that the pass manager is anchored on. This updates the
`-pass-pipeline` argument format to include the anchor op as well, so
that the printed form of a pipeline can be directly passed to
`-pass-pipeline`. In most cases this requires updating
`-pass-pipeline='pipeline'` to
`-pass-pipeline='builtin.module(pipeline)'`.

This also fixes an outdated assert that prevented running a
`PassManager` anchored on `'any'`.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D134900
2022-11-03 11:36:12 -04:00

42 lines
1.2 KiB
MLIR

// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline='builtin.module(func.func(canonicalize{top-down=true}))' | FileCheck %s --check-prefix=TD
// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline='builtin.module(func.func(canonicalize))' | FileCheck %s --check-prefix=BU
// BU-LABEL: func @default_insertion_position
// TD-LABEL: func @default_insertion_position
func.func @default_insertion_position(%cond: i1) {
// Constant should be folded into the entry block.
// BU: arith.constant 2
// BU-NEXT: scf.if
// TD: arith.constant 2
// TD-NEXT: scf.if
scf.if %cond {
%0 = arith.constant 1 : i32
%2 = arith.addi %0, %0 : i32
"foo.yield"(%2) : (i32) -> ()
}
return
}
// This shows that we don't pull the constant out of the region because it
// wants to be the insertion point for the constant.
// BU-LABEL: func @custom_insertion_position
// TD-LABEL: func @custom_insertion_position
func.func @custom_insertion_position() {
// BU: test.one_region_op
// BU-NEXT: arith.constant 2
// TD: test.one_region_op
// TD-NEXT: arith.constant 2
"test.one_region_op"() ({
%0 = arith.constant 1 : i32
%2 = arith.addi %0, %0 : i32
"foo.yield"(%2) : (i32) -> ()
}) : () -> ()
return
}