diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp --- a/mlir/lib/Transforms/Utils/DialectConversion.cpp +++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp @@ -364,11 +364,6 @@ // If the argument is still used, replace it with the generated cast. if (!origArg.use_empty()) origArg.replaceAllUsesWith(mapping.lookupOrDefault(castValue)); - - // If all users of the cast were removed, we can drop it. Otherwise, keep - // the operation alive and let the user handle any remaining usages. - if (castValue.use_empty() && castValue.getDefiningOp()) - castValue.getDefiningOp()->erase(); } } }