This is an archive of the discontinued LLVM Phabricator instance.

[mlir][scf] Canonicalize scf.while with unused results
ClosedPublic

Authored by Hardcode84 on Nov 19 2021, 3:07 PM.

Diff Detail

Event Timeline

Hardcode84 created this revision.Nov 19 2021, 3:07 PM
Hardcode84 requested review of this revision.Nov 19 2021, 3:07 PM
bondhugula added inline comments.
mlir/lib/Dialect/SCF/SCF.cpp
2259

Doc comment please.

2268–2315

Code comments needed for the major blocks.

2306

Stray semi-colon?

mlir/test/Dialect/SCF/canonicalize.mlir
822–830

%arg0 <--- avoid matching numbered SSA values. Use .* or match.

review comments

Hardcode84 marked 3 inline comments as done.Nov 20 2021, 11:19 AM
bondhugula added inline comments.Nov 22 2021, 12:10 AM
mlir/lib/Dialect/SCF/SCF.cpp
2259

Nit: Consider rephrasing this way to avoid ambiguity.

/// Remove WhileOp results that are also unused in after block.

2259

Terminate comments with a full stop -- here and everywhere below.

2318

Code comment here.

Hardcode84 added inline comments.Nov 22 2021, 1:03 AM
mlir/lib/Dialect/SCF/SCF.cpp
2318

In this specific block everything should clear from the code itself, commenting it like // Replacing old condition terminator will just add more noise

fix comments

Hardcode84 marked 2 inline comments as done.Nov 22 2021, 1:28 AM
ftynse accepted this revision.Nov 22 2021, 3:57 AM
ftynse added inline comments.
mlir/lib/Dialect/SCF/SCF.cpp
2326

In-place mutation of block argument may be problematic if this ever used in the dialect conversion infra (greedy rewriter in the canonicalization is fine though). Please add a big warning in the top-level documentation of this pattern and a remark comment here.

Or, ideally, figure out a way of achieving the same behavior. Something like mergeBlocks could work.

This revision is now accepted and ready to land.Nov 22 2021, 3:57 AM

use mergeBlocks

This revision was automatically updated to reflect the committed changes.