-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mlir] Fix worklist bug in MultiOpPatternRewriteDriver
When `strict = true`, only pre-existing and newly-created ops are rewritten and/or folded. Such ops are stored in `strictModeFilteredOps`. Newly-created ops were previously added to `strictModeFilteredOps` after calling `addToWorklist` (via `GreedyPatternRewriteDriver::notifyOperationInserted`). Therefore, newly-created ops were never added to the worklist. Also fix a test case that should have gone into an infinite loop (`test.replace_with_new_op` was replaced with itself, which should have caused the op to be rewritten over and over), but did not due to this bug. Differential Revision: https://reviews.llvm.org/D141141
- Loading branch information
1 parent
089a544
commit 0e47355
Showing
3 changed files
with
39 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,39 @@ | ||
// RUN: mlir-opt -allow-unregistered-dialect -test-strict-pattern-driver %s | FileCheck %s | ||
|
||
// CHECK-LABEL: @test_erase | ||
// CHECK-LABEL: func @test_erase | ||
// CHECK: test.arg0 | ||
// CHECK: test.arg1 | ||
// CHECK-NOT: test.erase_op | ||
func.func @test_erase() { | ||
%0 = "test.arg0"() : () -> (i32) | ||
%1 = "test.arg1"() : () -> (i32) | ||
%erase = "test.erase_op"(%0, %1) : (i32, i32) -> (i32) | ||
return | ||
} | ||
|
||
// CHECK-LABEL: @test_insert_same_op | ||
// CHECK-LABEL: func @test_insert_same_op | ||
// CHECK: "test.insert_same_op"() {skip = true} | ||
// CHECK: "test.insert_same_op"() {skip = true} | ||
func.func @test_insert_same_op() { | ||
%0 = "test.insert_same_op"() : () -> (i32) | ||
return | ||
} | ||
|
||
// CHECK-LABEL: @test_replace_with_same_op | ||
func.func @test_replace_with_same_op() { | ||
%0 = "test.replace_with_same_op"() : () -> (i32) | ||
// CHECK-LABEL: func @test_replace_with_new_op | ||
// CHECK: %[[n:.*]] = "test.new_op" | ||
// CHECK: "test.dummy_user"(%[[n]]) | ||
// CHECK: "test.dummy_user"(%[[n]]) | ||
func.func @test_replace_with_new_op() { | ||
%0 = "test.replace_with_new_op"() : () -> (i32) | ||
%1 = "test.dummy_user"(%0) : (i32) -> (i32) | ||
%2 = "test.dummy_user"(%0) : (i32) -> (i32) | ||
return | ||
} | ||
|
||
// CHECK-LABEL: func @test_replace_with_erase_op | ||
// CHECK-NOT: test.replace_with_new_op | ||
// CHECK-NOT: test.erase_op | ||
func.func @test_replace_with_erase_op() { | ||
"test.replace_with_new_op"() {create_erase_op} : () -> () | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters