This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Fixed v_swap_b32 match
ClosedPublic

Authored by rampitec on Oct 16 2020, 3:28 PM.

Details

Summary
  1. Fixed liveness issue with implicit kills.
  2. Fixed potential problem with an indirect mov.

Fixes: SWDEV-256848

Diff Detail

Event Timeline

rampitec created this revision.Oct 16 2020, 3:28 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 16 2020, 3:28 PM
rampitec requested review of this revision.Oct 16 2020, 3:28 PM

Couldn't this try to preserve the implicit operands?

Couldn't this try to preserve the implicit operands?

It can be implicit def or implicit kill. In both cases verifier will complain if it is dropped. Then the problem is there can be other instructions in between of the combined three and correct licenses may be needed in that range. That is probably possible to preserve implicit operands on the move at the insertion point and carry it over to the swap, but I am not so sure about the other two. Insert there an IMPLICIT_DEF or KILL?

rampitec updated this revision to Diff 299467.Oct 20 2020, 2:12 PM

Preserve implicit operands on the mov at insertion point.

rampitec updated this revision to Diff 299492.Oct 20 2020, 3:24 PM

Preserve implicit operands.

arsenm added inline comments.Oct 21 2020, 9:08 AM
llvm/lib/Target/AMDGPU/SIShrinkInstructions.cpp
442–447

Rather than special casing exec, this should check if the number of operands matches the number in the MCInstrDesc

rampitec updated this revision to Diff 299721.Oct 21 2020, 9:24 AM
rampitec marked an inline comment as done.

Do not specaial case implicit exec.

arsenm accepted this revision.Oct 21 2020, 9:57 AM
This revision is now accepted and ready to land.Oct 21 2020, 9:57 AM
This revision was automatically updated to reflect the committed changes.

When I build the latest version of the AMDGPU target, I get the warning shown below, which was treated as an error. I believe it started happening with this revision. I'm running on Windows.

Does it need to be:

if (Size > 1 && (I->getNumImplicitOperands() > (I->isCopy() ? 0U : 1U)))

...SIShrinkInstructions.cpp(551): warning C4018: '>': signed/unsigned mismatch

This revision is now accepted and ready to land.Oct 24 2020, 11:04 AM

Yes, making the 0 and 1 unsigned fixes the problem.

Yes, making the 0 and 1 unsigned fixes the problem.

Changed to 0U and 1U in ad8131bb03d0abd9e0586b9fa91d45cbf90ca83e.
This is a somewhat weird warning given strictly positive literals though.

Yes, I was rather surprised about the warning, too. This is the first time I've seen it, though I've been working on LLVM for only a couple of months.

Thanks!