[mlir] spelling and style changes in ReconcileUnrealizedCasts.cpp. NFC.

This commit is contained in:
Alex Zinenko 2021-09-10 14:08:15 +02:00
parent 3d3017d344
commit 61bc6aa5a7
1 changed files with 9 additions and 7 deletions

View File

@ -1,4 +1,4 @@
//===- ReoncileUnrealizedCasts.cpp - Eliminate noop unrealized casts ------===// //===- ReconcileUnrealizedCasts.cpp - Eliminate noop unrealized casts -----===//
// //
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information. // See https://llvm.org/LICENSE.txt for license information.
@ -32,15 +32,16 @@ struct UnrealizedConversionCastPassthrough
LogicalResult matchAndRewrite(UnrealizedConversionCastOp op, LogicalResult matchAndRewrite(UnrealizedConversionCastOp op,
PatternRewriter &rewriter) const override { PatternRewriter &rewriter) const override {
// Match the casts that are _only_ used by other casts, with the overall
// cast being a trivial noop: A->B->A.
auto users = op->getUsers(); auto users = op->getUsers();
if (!llvm::all_of(users, [&](Operation *user) { if (!llvm::all_of(users, [&](Operation *user) {
if (auto other = dyn_cast<UnrealizedConversionCastOp>(user)) { if (auto other = dyn_cast<UnrealizedConversionCastOp>(user))
return other.getResultTypes() == op.inputs().getTypes() && return other.getResultTypes() == op.inputs().getTypes() &&
other.inputs() == op.outputs(); other.inputs() == op.outputs();
}
return false; return false;
})) { })) {
return rewriter.notifyMatchFailure(op, "live unrealized conversion"); return rewriter.notifyMatchFailure(op, "live unrealized conversion cast");
} }
for (Operation *user : users) for (Operation *user : users)
@ -52,8 +53,9 @@ struct UnrealizedConversionCastPassthrough
}; };
/// Pass to simplify and eliminate unrealized conversion casts. /// Pass to simplify and eliminate unrealized conversion casts.
struct FinalizeToLLVM : public ReconcileUnrealizedCastsBase<FinalizeToLLVM> { struct ReconcileUnrealizedCasts
FinalizeToLLVM() = default; : public ReconcileUnrealizedCastsBase<ReconcileUnrealizedCasts> {
ReconcileUnrealizedCasts() = default;
void runOnOperation() override { void runOnOperation() override {
RewritePatternSet patterns(&getContext()); RewritePatternSet patterns(&getContext());
@ -74,5 +76,5 @@ void mlir::populateReconcileUnrealizedCastsPatterns(
} }
std::unique_ptr<Pass> mlir::createReconcileUnrealizedCastsPass() { std::unique_ptr<Pass> mlir::createReconcileUnrealizedCastsPass() {
return std::make_unique<FinalizeToLLVM>(); return std::make_unique<ReconcileUnrealizedCasts>();
} }