This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Affine] Revisit fusion candidates after successful fusion
ClosedPublic

Authored by dcaballe on Jun 10 2020, 12:37 PM.

Details

Summary

Current fusion algorithm doesn't have full support for multi-store producers.
For some scenarios, this means that some loop nests may or may not be fused
depending on the order they are visited. For example, if we have A->B, A->C, B->C
and try to fuse A+B first, it'll fail due to A's multiple outgoing edges. However,
after fusing B+C, A would have a single outgoing edge and could be fused. This is
currently not happening if we visit A before fusing B+C because we do not visit A
again after B+C fusion.

This patch changes the fusion algorithm so that after fusing two loop nests (B+C)
we revisit previously visited nodes (A) so that they are considered again for
fusion in the context of the new fused loop nest.

Diff Detail

Event Timeline

dcaballe created this revision.Jun 10 2020, 12:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 10 2020, 12:37 PM

The reasoning is sound to me, but deferring approval to Andy who understands this algorithm.

bondhugula accepted this revision.Jun 11 2020, 6:49 AM

Thanks for improving this. Agree that there may be an opportunity to make things more robust.

mlir/test/Transforms/loop-fusion.mlir
2528–2537

Nice.

This revision is now accepted and ready to land.Jun 11 2020, 6:49 AM
This revision was automatically updated to reflect the committed changes.

Thanks for improving this. Looks good to me...