Skip to content

Commit baa6627

Browse files
authored
[MLIR][Transforms] Fix dialect conversion inverse mapping (#104648)
Inverse mapping needs to be updated for the result that was remapped (it was previously only updated halfway).
1 parent 27dc247 commit baa6627

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

mlir/lib/Transforms/Utils/DialectConversion.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2527,6 +2527,7 @@ LogicalResult OperationConverter::legalizeConvertedOpResultTypes(
25272527
opReplacement->getConverter());
25282528
rewriterImpl.mapping.map(result, castValue);
25292529
inverseMapping[castValue].push_back(result);
2530+
llvm::erase(inverseMapping[newValue], result);
25302531
}
25312532
}
25322533

mlir/test/Transforms/test-legalize-target-materialization-no-uses.mlir

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: mlir-opt -test-target-materialization-with-no-uses %s | FileCheck %s
1+
// RUN: mlir-opt -test-target-materialization-with-no-uses -split-input-file %s | FileCheck %s
22

33
// The conversion is set up as follows:
44
// - type_changer ops are illegal;
@@ -25,3 +25,12 @@ func.func @foo() {
2525
"test.type_consumer"(%2) : (i64) -> ()
2626
return
2727
}
28+
29+
// -----
30+
31+
// CHECK-LABEL: @direct_forward
32+
func.func @direct_forward(%arg0 : i16) -> i16 {
33+
// CHECK-NEXT: return
34+
%0 = "test.type_changer"(%arg0) : (i16) -> i16
35+
return %0 : i16
36+
}

0 commit comments

Comments
 (0)