This is an archive of the discontinued LLVM Phabricator instance.

[MachineCopyPropagation] More robust isForwardableRegClassCopy
ClosedPublic

Authored by foad on Mar 17 2022, 4:42 AM.

Details

Summary

Change the implementation of isForwardableRegClassCopy so that it
does not rely on getMinimalPhysRegClass. Instead, iterate over all
classes looking for any that satisfy a required property.

NFCI on current upstream targets, but this copes better with
downstream AMDGPU changes where some new smaller classes have been
introduced, which was breaking regclass equality tests in the old
code like:

if (UseDstRC != CrossCopyRC && CopyDstRC == CrossCopyRC)

Diff Detail

Unit TestsFailed

Event Timeline

foad created this revision.Mar 17 2022, 4:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 17 2022, 4:42 AM
Herald added subscribers: hiraditya, tpr. · View Herald Transcript
foad requested review of this revision.Mar 17 2022, 4:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 17 2022, 4:42 AM
foad added a reviewer: arsenm.Mar 17 2022, 7:51 AM
This revision is now accepted and ready to land.Mar 17 2022, 8:34 AM
foad added a comment.Mar 17 2022, 8:58 AM

LGTM

Thanks. I'd still like to hear from @vangthao or others who were involved in D108011.

Would this disallow AGPR to AGPR copy propagation completely on sub-targets with no AGPR->AGPR copy capability? I think in some cases we can still propagate an AGPR. For example:

liveins: $agpr0
  $agpr1 = COPY $agpr0
  $agpr2 = COPY $agpr1
  $agpr3 = COPY $agpr2

$agpr0 can be propagated and we would not require more than 1 set of v_accvgpr_read/write when expanding the copys.

foad updated this revision to Diff 416895.Mar 21 2022, 4:45 AM

Rebase.

foad added a comment.Mar 21 2022, 4:46 AM

Would this disallow AGPR to AGPR copy propagation completely on sub-targets with no AGPR->AGPR copy capability?

You're right, it does. I have added a test case for this and rebased the patch to show the effect. I will work on this.

foad updated this revision to Diff 416963.Mar 21 2022, 8:27 AM

Allow the forwarded copy to be cross-class, but only if the original copy was cross-class.

vangthao accepted this revision.Mar 21 2022, 9:22 AM

LGTM.