-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[mlir] Do not merge blocks during canonicalization by default #95057
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -827,11 +827,13 @@ static LogicalResult mergeIdenticalBlocks(RewriterBase &rewriter, | |
/// elimination, as well as some other DCE. This function returns success if any | ||
/// of the regions were simplified, failure otherwise. | ||
LogicalResult mlir::simplifyRegions(RewriterBase &rewriter, | ||
MutableArrayRef<Region> regions) { | ||
MutableArrayRef<Region> regions, | ||
bool mergeBlocks) { | ||
bool eliminatedBlocks = succeeded(eraseUnreachableBlocks(rewriter, regions)); | ||
bool eliminatedOpsOrArgs = succeeded(runRegionDCE(rewriter, regions)); | ||
bool mergedIdenticalBlocks = | ||
succeeded(mergeIdenticalBlocks(rewriter, regions)); | ||
bool mergedIdenticalBlocks = false; | ||
if (mergeBlocks) | ||
mergedIdenticalBlocks = succeeded(mergeIdenticalBlocks(rewriter, regions)); | ||
Comment on lines
+834
to
+836
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be written in one line:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't really like the short circuit with side effects: this would obscure the control flow IMO. |
||
return success(eliminatedBlocks || eliminatedOpsOrArgs || | ||
mergedIdenticalBlocks); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline='builtin.module(func.func(canonicalize))' -split-input-file | FileCheck %s | ||
// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline='builtin.module(func.func(canonicalize{region-simplify=aggressive}))' -split-input-file | FileCheck %s | ||
|
||
// Check the simple case of single operation blocks with a return. | ||
|
||
|
@@ -275,3 +275,18 @@ func.func @mismatch_dominance() -> i32 { | |
^bb4(%3: i32): | ||
return %3 : i32 | ||
} | ||
|
||
// CHECK-LABEL: func @dead_dealloc_fold_multi_use | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Drop extra line. |
||
func.func @dead_dealloc_fold_multi_use(%cond : i1) { | ||
// CHECK-NEXT: return | ||
%a = memref.alloc() : memref<4xf32> | ||
cf.cond_br %cond, ^bb1, ^bb2 | ||
|
||
^bb1: | ||
memref.dealloc %a: memref<4xf32> | ||
return | ||
|
||
^bb2: | ||
memref.dealloc %a: memref<4xf32> | ||
return | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doc comment for this.