This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Vector] Extend xfer_read(extract)->scalar load to support multiple uses
ClosedPublic

Authored by dcaballe on May 17 2023, 1:06 PM.

Details

Summary

This patch extends the vector.extract(vector.transfer_read) -> scalar
load patterns to support vector.transfer_read with multiple uses. For
now, we check that all the uses are vector.extract operations.
Supporting multiple uses is predicated under a flag.

Diff Detail

Event Timeline

dcaballe created this revision.May 17 2023, 1:06 PM
Herald added a project: Restricted Project. · View Herald Transcript
dcaballe requested review of this revision.May 17 2023, 1:06 PM

I'm curious that is there a case we want to disable the flag? Why it is not enabled by default?

mlir/include/mlir/Dialect/Vector/Transforms/LoweringPatterns.h
120

can we add a doc about what it means if allowMultipleUses is enabled and is disabled?

mlir/lib/Dialect/Vector/Transforms/VectorTransferOpTransforms.cpp
590–591

I think this can be merged into one isa?

664–665

There are same checks in other pattern. Can we refactor them to a common method?

dcaballe updated this revision to Diff 523656.May 18 2023, 10:42 PM
dcaballe marked 3 inline comments as done.

Address comments

Great feedback! Thanks!

I'm curious that is there a case we want to disable the flag? Why it is not enabled by default?

The original comment says "xfer result must have a single use. Otherwise, it may be better to perform a vector load.". Not sure what the context is. Perhaps if there are scalar and vector uses... or if the cache line is evicted before all the scalar loads are completed (weird)...
In any case, I think it's better to preserve the original behavior for now until we can learn more about it.

hanchung accepted this revision.May 19 2023, 10:02 AM

Great feedback! Thanks!

I'm curious that is there a case we want to disable the flag? Why it is not enabled by default?

The original comment says "xfer result must have a single use. Otherwise, it may be better to perform a vector load.". Not sure what the context is. Perhaps if there are scalar and vector uses... or if the cache line is evicted before all the scalar loads are completed (weird)...
In any case, I think it's better to preserve the original behavior for now until we can learn more about it.

Got it, thanks!

This revision is now accepted and ready to land.May 19 2023, 10:02 AM
awarzynski added inline comments.May 19 2023, 11:40 AM
mlir/include/mlir/Dialect/Vector/Transforms/LoweringPatterns.h
115–118

Sorry, it's a bit late at my end, so perhaps I'm misreading this myself :) Please double-check.

awarzynski added inline comments.May 19 2023, 11:55 AM
mlir/lib/Dialect/Vector/Transforms/VectorTransferOpTransforms.cpp
612

IIUC, this method will rewrite unconditionally. But match will not match unconditionally. Put differently - this comment needs updating, right?

Thanks! Updating doc and landing. Let me know if there are any other doc issues. I'll be happy to address them separately.

mlir/include/mlir/Dialect/Vector/Transforms/LoweringPatterns.h
115–118

Thanks! It looks like it was also late at my end when I wrote that :)

mlir/lib/Dialect/Vector/Transforms/VectorTransferOpTransforms.cpp
612

Updated doc, thanks!

This revision was landed with ongoing or failed builds.May 19 2023, 2:06 PM
This revision was automatically updated to reflect the committed changes.