This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] In SIMemoryLegalizer assume all atomic ops have memoperands
Changes PlannedPublic

Authored by foad on Dec 7 2021, 2:49 AM.

Details

Summary

Remove the conservative handling of maybeAtomic ops with no
memoperands. In practice this path is untested because all maybeAtomic
ops do have memoperands. Remove various unused default values for fields
in SIMemOpInfo.

If we add new ops without memoperands in future it's better to hit the
assertion in constructFromMIWithMMO early than to have them handled
conservatively (which is correct but slow) and only find out about the
performance problem later.

Diff Detail

Event Timeline

foad created this revision.Dec 7 2021, 2:49 AM
foad requested review of this revision.Dec 7 2021, 2:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 7 2021, 2:49 AM
arsenm added a comment.Dec 7 2021, 2:26 PM

This at least needs to be backed up with a verifier change.

Arguably this should be a general verifier property if we really can commit to machine passes never dropping MMOs

t-tye added a comment.Dec 7 2021, 7:06 PM

My understanding was that it was not guaranteed that an MI instruction has a MMO. That passes could drop the MMO. Are you saying that is not the case? As Matt says, if that is the case the verifier needs to enforce that.

foad planned changes to this revision.Dec 8 2021, 2:27 AM

This at least needs to be backed up with a verifier change.

I'm not ready to assert that all mayLoad/mayStore MIs have an MMO. I'm only saying that this seems to be true:

  • for MIs used by the AMDGPU backend,
  • which have the AMDGPU-specific maybeAtomic flag set.

I don't really understand the point of the maybeAtomic flag, so I might work on removing that first and then revisit this patch.

Arguably this should be a general verifier property if we really can commit to machine passes never dropping MMOs

I wasn't aware that passes were allowed to drop MMOs. Do you know of any specific examples? It seems like a bit of an odd situation if they are allowed to, but it never actually happens in practice.

arsenm added a comment.Dec 8 2021, 5:49 AM

I wasn't aware that passes were allowed to drop MMOs. Do you know of any specific examples? It seems like a bit of an odd situation if they are allowed to, but it never actually happens in practice.

The verifier doesn't enforce an MMO requirement, so it's defacto. Plus hasUnorderedMemoryRef implies this is OK.

I think the concern would be if you did something like if convert 2 conditional loads into one load with a select on the pointer. You would have to common the memory operands somehow (which I guess would be dropping the IR reference and selecting the most conservative flags of the pair)