This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][Affine] Improve load elimination
ClosedPublic

Authored by rikhuijzer on Jul 8 2023, 7:20 AM.

Details

Summary

Common Subexpression Eliminiation (CSE) was applied via loadCSE to remove redundant loads from code. However, this process failed in cases where there were redundant stores in between the redundant loads. In those cases, the redundant stores would be seen as having an intervening effect during the loadCSE step.

This patch fixes that by moving the load CSE behind the store CSE.

Fixes #62639.

Diff Detail

Event Timeline

rikhuijzer created this revision.Jul 8 2023, 7:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 8 2023, 7:20 AM
rikhuijzer requested review of this revision.Jul 8 2023, 7:20 AM
bondhugula accepted this revision.Jul 9 2023, 3:02 AM

Thanks for improving this. Please add a commit summary -- along the lines of your code comment at L1112.

mlir/lib/Dialect/Affine/Utils/Utils.cpp
1003

loadB should not dominate loadA

1114

as intervening -> as having an intervening

This revision is now accepted and ready to land.Jul 9 2023, 3:02 AM
rikhuijzer updated this revision to Diff 538415.Jul 9 2023, 3:27 AM

Update comment

rikhuijzer updated this revision to Diff 538416.Jul 9 2023, 3:31 AM

Make comments inside loadCSE more clear

rikhuijzer edited the summary of this revision. (Show Details)Jul 9 2023, 3:39 AM
This revision was automatically updated to reflect the committed changes.

Thanks for improving this. Please add a commit summary -- along the lines of your code comment at L1112.

I've updated the patch description in order to let that automatically update the commit summary. However, I just saw after committing that the commit message wasn't automatically updated. Apologies for that. I think it's not worth fixing this anymore now. I'll pay more attention next time!

Thanks for improving this. Please add a commit summary -- along the lines of your code comment at L1112.

I've updated the patch description in order to let that automatically update the commit summary. However, I just saw after committing that the commit message wasn't automatically updated. Apologies for that. I think it's not worth fixing this anymore now. I'll pay more attention next time!

No problem. In the future, you can do an arc diff --edit --verbatim -- that would update the commit summary on the commit as well as Phab here in one shot.

Thanks for improving this. Please add a commit summary -- along the lines of your code comment at L1112.

I've updated the patch description in order to let that automatically update the commit summary. However, I just saw after committing that the commit message wasn't automatically updated. Apologies for that. I think it's not worth fixing this anymore now. I'll pay more attention next time!

No problem. In the future, you can do an arc diff --edit --verbatim -- that would update the commit summary on the commit as well as Phab here in one shot.

Yes, I was already wondering about that. Thank you