[PATCH] D97316: AMDGPU: Add even aligned VGPR/AGPR register classes

Stanislav Mekhanoshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 23 13:28:45 PST 2021


rampitec added a comment.

In D97316#2582970 <https://reviews.llvm.org/D97316#2582970>, @arsenm wrote:

> In D97316#2582947 <https://reviews.llvm.org/D97316#2582947>, @rampitec wrote:
>
>> In D97316#2582931 <https://reviews.llvm.org/D97316#2582931>, @arsenm wrote:
>>
>>> In D97316#2582925 <https://reviews.llvm.org/D97316#2582925>, @rampitec wrote:
>>>
>>>> I do not think it will help. There will be the same issue as with reserved registers. Assume you have VReg_128_align2. For sure RA will allocate an aligned register. But something like coalescer will happily use sub1_sub2 on it and you will end up with an unaligned physreg at the end. To make this working you need to make sure these registers do not have unaligned subregs.
>>>
>>> This is already the case. The subregister indexes are considered unsupported by the class (e.g. getMatchingSuperRegClass and the composeSubReg* functions will fail)
>>
>> Do you mean because to get a subreg a pass needs to query a subclass and aligned classes have only aligned subclasses? Are you sure there is no other way to get a subreg?
>
> Yes, the verifier fails if you use an unaligned subregister with an aligned class. For example, the custom verifier check fails on this case:
>
>   GLOBAL_STORE_DWORDX2 %0, %5:vreg_128_align2.sub1_sub2, 0, 0, 0, 0, 0, implicit $exec
>
> The general verifier catches this problem in other cases. Technically you need to verify the register class supports a given subreg index and constrain/copy a register to a compatible class (for example GlobalISel selectG_INSERT checks for class compatibility in cases where we would want to use unaligned indexes on SGPR tuples)

You can probably remove check from SIRegisterInfo::shouldCoalesce():

  if (ST.hasGFX90AInsts() && !isSGPRClass(NewRC) &&
      (getChannelFromSubReg(DstSubReg) & 1) !=
      (getChannelFromSubReg(SubReg) & 1))
    return false;

If coalesce-vgpr-alignment.ll and hiloeo-odd-coalesce.ll pass then you are right.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97316/new/

https://reviews.llvm.org/D97316



More information about the llvm-commits mailing list