This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Use unordered indexed loads for MGATHER.
ClosedPublic

Authored by craig.topper on Jul 14 2021, 5:13 PM.

Details

Summary

I don't think the semantics of the llvm masked gather intrinsic care
about the order the elements are loaded. For example, type legalization
by splitting will chain them in parallel. This is different than
scatter which we do chain in order.

Diff Detail

Event Timeline

craig.topper created this revision.Jul 14 2021, 5:13 PM
craig.topper requested review of this revision.Jul 14 2021, 5:13 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 14 2021, 5:13 PM
Herald added a subscriber: MaskRay. · View Herald Transcript

I'm glad you brought this up. I remember having my doubts when first doing the lowering for MGATHER. I can't remember if we had a discussion around that or not but it was on my mind. I think at some point in development I went with the conservative option and it wasn't caught in review. I suspect it's okay to use unordered loads. Do you know if other targets do?

I'm glad you brought this up. I remember having my doubts when first doing the lowering for MGATHER. I can't remember if we had a discussion around that or not but it was on my mind. I think at some point in development I went with the conservative option and it wasn't caught in review. I suspect it's okay to use unordered loads. Do you know if other targets do?

X86 documentation for gather says "The values may be read from memory in any order. Memory ordering with other instructions follows the Intel64 memory-ordering model."

ARM's documentation makes no mention of ordering that I can find.

I think the difference between of order and unordered load is when the exception happens on memory access,
and the document said "However, using this intrinsic prevents exceptions on memory access to masked-off lanes."
IMO, it makes sense to me to assume mgather is unordered access, because intrinsic users have to set masked-off to avoid exception.

This revision is now accepted and ready to land.Jul 20 2021, 6:31 AM
This revision was landed with ongoing or failed builds.Jul 20 2021, 8:46 AM
This revision was automatically updated to reflect the committed changes.