This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Normalize memrefs in LoadOp and StoreOp of Standard Ops
ClosedPublic

Authored by imaihal on Sep 23 2020, 8:24 AM.

Details

Summary

Added a trait, MemRefsNormalizable in LoadOp and StoreOp of Standard Ops
to normalize input memrefs in LoadOp and StoreOp.

Related revision: https://reviews.llvm.org/D86236

Diff Detail

Event Timeline

imaihal created this revision.Sep 23 2020, 8:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 23 2020, 8:25 AM
imaihal requested review of this revision.Sep 23 2020, 8:25 AM

When we use load and store ops like the test in this patch, the --normalize-memrefs does not work. This patch fix it by adding MemRefsNormalizable trait in load and store ops.
If we can use affine.load and affine.store in this test, the normalization works, but sometimes affine.load can not be used. In the case, we need to use std.load.

More practical example is here. https://github.com/llvm/llvm-project/blob/master/mlir/test/Dialect/Linalg/affine.mlir#L92-L94 affine.load can not be used here.

@bondhugula @AlexEichenberger @avarmapml Could you review this patch?

bondhugula accepted this revision.Sep 23 2020, 9:21 AM

Thanks for adding this!

mlir/test/Transforms/normalize-memrefs-ops.mlir
64

Nit: for readability, it may be good to define the map to use here right before the function instead of reusing #map0 defined all the way up. You could use say:

#map_tile = ...

This revision is now accepted and ready to land.Sep 23 2020, 9:21 AM
AlexEichenberger accepted this revision.Sep 23 2020, 9:37 AM

Thanks, glad to see that the traits make such changes easy... Please correct Uday's nit, and its good to go.

imaihal updated this revision to Diff 293904.Sep 23 2020, 6:16 PM

Reflected the comment about map, and rebased

imaihal marked an inline comment as done.Sep 23 2020, 6:16 PM
bondhugula accepted this revision.Sep 23 2020, 6:45 PM

@AlexEichenberger

glad to see that the traits make such changes easy...

Yes. The traits are very useful. We might need to add them in other ops depending on use-case, but it is easy.

@bondhugula I don't have commit permission. Could you commit this patch?

This revision was automatically updated to reflect the committed changes.