[Mlir-commits] [mlir] [mlir][Transforms][WIP] Dialect conversion: Fix bug in `computeNecessaryMaterializations` (PR #104630)
Matthias Springer
llvmlistbot at llvm.org
Fri Aug 16 11:44:59 PDT 2024
https://github.com/matthias-springer created https://github.com/llvm/llvm-project/pull/104630
There was a typo in the code path that removes unnecessary materializations.
Before: Update `opResult` (result of an op different from `user`) in mapping and remove `user`.
```
replaceMaterialization(rewriterImpl, opResult, inputOperands,
inverseMapping);
necessaryMaterializations.remove(materializationOps.lookup(user));
```
After: Update `user->getResults()` in mapping and remove `user`.
```
replaceMaterialization(rewriterImpl, user->getResults(), inputOperands,
inverseMapping);
necessaryMaterializations.remove(materializationOps.lookup(user));
```
TODO: test case
>From 43c60fbeefc198eea8c426a9c7a71221d3e9f1a6 Mon Sep 17 00:00:00 2001
From: Matthias Springer <mspringer at nvidia.com>
Date: Fri, 16 Aug 2024 20:40:39 +0200
Subject: [PATCH] [mlir][Transforms][WIP] Dialect conversion: Fix bug in
`computeNecessaryMaterializations`
There was a typo in the code path that removes unnecessary materializations.
Before: Update `opResult` (result of an op different from `user`) in mapping and remove `user`.
```
replaceMaterialization(rewriterImpl, opResult, inputOperands,
inverseMapping);
necessaryMaterializations.remove(materializationOps.lookup(user));
```
After: Update `user->getResults()` in mapping and remove `user`.
```
replaceMaterialization(rewriterImpl, user->getResults(), inputOperands,
inverseMapping);
necessaryMaterializations.remove(materializationOps.lookup(user));
```
TODO: test case
---
mlir/lib/Transforms/Utils/DialectConversion.cpp | 2 +-
mlir/test/Transforms/test-legalize-type-conversion.mlir | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp
index 11e593cebc09b3..8a4c7463a69a95 100644
--- a/mlir/lib/Transforms/Utils/DialectConversion.cpp
+++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp
@@ -2680,7 +2680,7 @@ static void computeNecessaryMaterializations(
if (!castOp)
continue;
if (castOp->getResultTypes() == inputOperands.getTypes()) {
- replaceMaterialization(rewriterImpl, opResult, inputOperands,
+ replaceMaterialization(rewriterImpl, user->getResults(), inputOperands,
inverseMapping);
necessaryMaterializations.remove(materializationOps.lookup(user));
}
diff --git a/mlir/test/Transforms/test-legalize-type-conversion.mlir b/mlir/test/Transforms/test-legalize-type-conversion.mlir
index 252b990210a180..cf2c9f6a8ec441 100644
--- a/mlir/test/Transforms/test-legalize-type-conversion.mlir
+++ b/mlir/test/Transforms/test-legalize-type-conversion.mlir
@@ -99,6 +99,7 @@ func.func @test_block_argument_not_converted() {
func.func @test_signature_conversion_no_converter() {
"test.signature_conversion_no_converter"() ({
// expected-error at below {{failed to legalize unresolved materialization from ('f64') to 'f32' that remained live after conversion}}
+ // expected-note at below {{see existing live user here}}
^bb0(%arg0: f32):
"test.type_consumer"(%arg0) : (f32) -> ()
"test.return"(%arg0) : (f32) -> ()
More information about the Mlir-commits
mailing list