This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Refactor shouldExpandAtomicRMWInIR [NFC]
AbandonedPublic

Authored by tmatheson on Apr 6 2022, 2:31 AM.

Details

Summary

Convert to a sequence of early returns to make the logic easier to follow.

Diff Detail

Event Timeline

tmatheson created this revision.Apr 6 2022, 2:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 6 2022, 2:31 AM
tmatheson requested review of this revision.Apr 6 2022, 2:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 6 2022, 2:31 AM
efriedma added a comment.EditedApr 6 2022, 5:05 PM

The logic is basically the following:

  1. If we can use LSE, return "none" and let isel lower it.
  2. If we can use outlined atomic helpers, return "none" and let SelectionDAG generate the outlined call.
  3. If we can use LLSC, use LLSC expansion
  4. If we can use cmpxchg, use cmpxchg expansion
  5. If we can't use any of the above, we... crash? Really, we shouldn't get here; we should call setMaxAtomicSizeInBitsSupported() and let AtomicExpand handle it.

The proposed refactoring seems to make it harder to understand this.

If you want to separate out "can use LSE" and "can use outlined atomic helpers" into separate functions/lambas, that would be an improvement, I guess.

tmatheson abandoned this revision.Apr 21 2022, 12:15 AM

Sorry I forgot to follow this up sooner. Looking at it again I think you are right so will drop this patch.