This is an archive of the discontinued LLVM Phabricator instance.

[MLIR] Fix incorrect removal of source loop in loop fusion
ClosedPublic

Authored by Groverkss on Nov 18 2021, 7:24 AM.

Details

Summary

This patch fixes a bug in loop fusion pass where the source loop was removed
even when the fused loop did not cover all iterations of the source loop.

This was because the fast hueristic check for checking if source loop and
fused loop have same iterations did not take into account steps in loop.

Diff Detail

Event Timeline

Groverkss created this revision.Nov 18 2021, 7:24 AM
Groverkss requested review of this revision.Nov 18 2021, 7:24 AM

Thanks a lot for the fix! LGTM. Just a minor comment.

mlir/test/Transforms/loop-fusion-4.mlir
165

Could you please check a bit more operations to make sure that fusion is actually happening in the second loop and that the first loop is the original one?

bondhugula accepted this revision.Nov 20 2021, 4:55 AM

LGTM - just one minor NFC comment to add to @dcaballe's comments above.

mlir/test/Transforms/loop-fusion-4.mlir
149

Can you add this test case slightly above where it's more appropriate (related to surrounding test cases) instead of at the end? Always appending to the file in general leads to more conflicts (downstream or otherwise) and spreads around various things arbitrarily in the file.

This revision is now accepted and ready to land.Nov 20 2021, 4:55 AM
Groverkss marked 2 inline comments as done.
  • Added more checks for test case and moved it to up to related tests

@dcaballe Is the test case fine now?

dcaballe accepted this revision.Nov 22 2021, 1:33 AM

Thanks for addressing the feedback. LGTM. Just one minor comment. Feel free to fix it a commit it directly.

Thanks!
Diego

mlir/test/Transforms/loop-fusion-4.mlir
100

since you are capturing idx_1, probably good to match here. That or not capture it.

Groverkss updated this revision to Diff 389022.Nov 22 2021, 1:16 PM
  • Match captured index in test case.
Groverkss marked an inline comment as done.Nov 22 2021, 1:16 PM
This revision was landed with ongoing or failed builds.Nov 22 2021, 1:25 PM
This revision was automatically updated to reflect the committed changes.