This is an archive of the discontinued LLVM Phabricator instance.

[MLIR] Simplify affine.if ops with trivial conditions
ClosedPublic

Authored by shashij-polymagelabs on Jun 10 2021, 2:24 AM.

Details

Summary

The commit simplifies affine.if ops :
The affine if operation gets removed if the condition is universally true or false and then/else block is merged with the parent block.

Signed-off-by: Shashij Gupta shashij.gupta@polymagelabs.com

Diff Detail

Event Timeline

shashij-polymagelabs requested review of this revision.Jun 10 2021, 2:24 AM

Some case styling issues.

mlir/lib/Dialect/Affine/IR/AffineOps.cpp
1912

AffineSet -> affineSet.

1932

block_terminator -> blockTerminator

bondhugula requested changes to this revision.Jun 10 2021, 2:44 AM
bondhugula added inline comments.
mlir/lib/Dialect/Affine/IR/AffineOps.cpp
1908

Nit: affine.If -> affine.if

1933

You can't use erase() in a rewrite pattern; eraseOp instead.

This revision now requires changes to proceed.Jun 10 2021, 2:44 AM
bondhugula added inline comments.Jun 10 2021, 2:44 AM
mlir/lib/Dialect/Affine/IR/AffineOps.cpp
1933

rewriter.eraseOp(*block_terminator)

This comment was removed by bondhugula.
mlir/lib/Dialect/Affine/IR/AffineOps.cpp
1908

Can you mark this as a TODO? A similar simplification can be done in those cases.

1912

AffineSet -> conditionSet
Avoid generic names.

Resolved comments

bondhugula accepted this revision.Jun 11 2021, 4:07 PM

Looks good - thanks!

This revision is now accepted and ready to land.Jun 11 2021, 4:07 PM
pr4tgpt accepted this revision.Jun 12 2021, 4:36 AM

LGTM!

This revision was automatically updated to reflect the committed changes.