[Mlir-commits] [mlir] [mlir][Transforms][NFC] Dialect Conversion: Earlier `isIgnored` check (PR #148360)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sat Jul 12 04:22:54 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
@llvm/pr-subscribers-mlir-core
Author: Matthias Springer (matthias-springer)
<details>
<summary>Changes</summary>
When legalizing an operation, the conversion driver skips "ignored" ops. Ops are ignored if they are inside of a recursively legal operation or if they were erased.
This commit moves the "is ignored" check a bit earlier: it is now checked before checking if the op is recursively legal. This is in preparation of the One-Shot Dialect Conversion refactoring: erased ops should not be accessed, not even for checking recursive legality.
This commit is NFC: When an op is erased, it is added to the set of ignored ops and we don't want to process it, regardless of legality. Nested ops are also added to the set of ignored ops when erasing an enclosing op.
---
Full diff: https://github.com/llvm/llvm-project/pull/148360.diff
1 Files Affected:
- (modified) mlir/lib/Transforms/Utils/DialectConversion.cpp (+10-9)
``````````diff
diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp
index d118fe422f2f2..645e6b8727968 100644
--- a/mlir/lib/Transforms/Utils/DialectConversion.cpp
+++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp
@@ -2089,6 +2089,16 @@ OperationLegalizer::legalize(Operation *op,
}
});
+ // Check to see if the operation is ignored and doesn't need to be converted.
+ bool isIgnored = rewriter.getImpl().isOpIgnored(op);
+ if (isIgnored) {
+ LLVM_DEBUG({
+ logSuccess(logger, "operation marked 'ignored' during conversion");
+ logger.startLine() << logLineComment;
+ });
+ return success();
+ }
+
// Check if this operation is legal on the target.
if (auto legalityInfo = target.isLegal(op)) {
LLVM_DEBUG({
@@ -2112,15 +2122,6 @@ OperationLegalizer::legalize(Operation *op,
return success();
}
- // Check to see if the operation is ignored and doesn't need to be converted.
- if (rewriter.getImpl().isOpIgnored(op)) {
- LLVM_DEBUG({
- logSuccess(logger, "operation marked 'ignored' during conversion");
- logger.startLine() << logLineComment;
- });
- return success();
- }
-
// If the operation isn't legal, try to fold it in-place.
// TODO: Should we always try to do this, even if the op is
// already legal?
``````````
</details>
https://github.com/llvm/llvm-project/pull/148360
More information about the Mlir-commits
mailing list