Skip to content

Commit cb7614e

Browse files
[mlir][Transforms] Dialect conversion: Fix bug in computeNecessaryMaterializations (#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)); ```
1 parent e6ceb29 commit cb7614e

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

mlir/lib/Transforms/Utils/DialectConversion.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2680,7 +2680,7 @@ static void computeNecessaryMaterializations(
26802680
if (!castOp)
26812681
continue;
26822682
if (castOp->getResultTypes() == inputOperands.getTypes()) {
2683-
replaceMaterialization(rewriterImpl, opResult, inputOperands,
2683+
replaceMaterialization(rewriterImpl, user->getResults(), inputOperands,
26842684
inverseMapping);
26852685
necessaryMaterializations.remove(materializationOps.lookup(user));
26862686
}

mlir/test/Transforms/test-legalize-type-conversion.mlir

+1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ func.func @test_block_argument_not_converted() {
9999
func.func @test_signature_conversion_no_converter() {
100100
"test.signature_conversion_no_converter"() ({
101101
// expected-error@below {{failed to legalize unresolved materialization from ('f64') to 'f32' that remained live after conversion}}
102+
// expected-note@below {{see existing live user here}}
102103
^bb0(%arg0: f32):
103104
"test.type_consumer"(%arg0) : (f32) -> ()
104105
"test.return"(%arg0) : (f32) -> ()

0 commit comments

Comments
 (0)