[Mlir-commits] [mlir] [MLIR][Transforms] Fix dialect conversion inverse mapping (PR #104648)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Fri Aug 16 17:11:10 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: Billy Zhu (zyx-billy)
<details>
<summary>Changes</summary>
Inverse mapping needs to be updated for the result that was remapped (it was previously only updated halfway).
---
Full diff: https://github.com/llvm/llvm-project/pull/104648.diff
2 Files Affected:
- (modified) mlir/lib/Transforms/Utils/DialectConversion.cpp (+1)
- (modified) mlir/test/Transforms/test-legalize-target-materialization-no-uses.mlir (+7)
``````````diff
diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp
index 11e593cebc09b3..e71b91c4e54cdf 100644
--- a/mlir/lib/Transforms/Utils/DialectConversion.cpp
+++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp
@@ -2527,6 +2527,7 @@ LogicalResult OperationConverter::legalizeConvertedOpResultTypes(
opReplacement->getConverter());
rewriterImpl.mapping.map(result, castValue);
inverseMapping[castValue].push_back(result);
+ llvm::erase(inverseMapping[newValue], result);
}
}
diff --git a/mlir/test/Transforms/test-legalize-target-materialization-no-uses.mlir b/mlir/test/Transforms/test-legalize-target-materialization-no-uses.mlir
index 19dd2b2ee4b2f2..04db95ba7a9bac 100644
--- a/mlir/test/Transforms/test-legalize-target-materialization-no-uses.mlir
+++ b/mlir/test/Transforms/test-legalize-target-materialization-no-uses.mlir
@@ -25,3 +25,10 @@ func.func @foo() {
"test.type_consumer"(%2) : (i64) -> ()
return
}
+
+// CHECK-LABEL: @direct_forward
+func.func @direct_forward(%arg0 : i16) -> i16 {
+ // CHECK-NEXT: return
+ %0 = "test.type_changer"(%arg0) : (i16) -> i16
+ return %0 : i16
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/104648
More information about the Mlir-commits
mailing list