
This is intended as a fast pattern rewrite driver for the cases when a simple walk gets the job done but we would still want to implement it in terms of rewrite patterns (that can be used with the greedy pattern rewrite driver downstream). The new driver is inspired by the discussion in https://github.com/llvm/llvm-project/pull/112454 and the LLVM Dev presentation from @matthias-springer earlier this week. This limitation comes with some limitations: * It does not repeat until a fixpoint or revisit ops modified in place or newly created ops. In general, it only walks forward (in the post-order). * `matchAndRewrite` can only erase the matched op or its descendants. This is verified under expensive checks. * It does not perform folding / DCE. We could probably relax some of these in the future without sacrificing too much performance.
12 lines
463 B
MLIR
12 lines
463 B
MLIR
// RUN: mlir-opt --pass-pipeline="builtin.module(test-greedy-patterns)" %s | FileCheck %s
|
|
|
|
// CHECK-LABEL: func @test_reorder_constants_and_match
|
|
func.func @test_reorder_constants_and_match(%arg0 : i32) -> (i32) {
|
|
// CHECK: %[[CST:.+]] = arith.constant 43
|
|
%cst = arith.constant 43 : i32
|
|
// CHECK: return %[[CST]]
|
|
%y = "test.op_commutative2"(%cst, %arg0) : (i32, i32) -> i32
|
|
%x = "test.op_commutative2"(%y, %arg0) : (i32, i32) -> i32
|
|
return %x : i32
|
|
}
|