This is an archive of the discontinued LLVM Phabricator instance.

AMDGPU/SI: Don't fix a PHI under uniform branch in SIFixSGPRCopies only when sources and destination are all sgprs
ClosedPublic

Authored by cfang on Jun 27 2017, 4:52 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

cfang created this revision.Jun 27 2017, 4:52 PM
arsenm added inline comments.Jun 27 2017, 5:04 PM
lib/Target/AMDGPU/SIFixSGPRCopies.cpp
608 ↗(On Diff #104312)

I think you should move the below phiHasVGPROperands check first rather than adding a second one

test/CodeGen/AMDGPU/vgpr-to-sgpr-phi.ll
3 ↗(On Diff #104312)

GCN check prefix

7 ↗(On Diff #104312)

It may be better to reformulate as a kernel for now, which will require a non-argument source for the VGPR

7–9 ↗(On Diff #104312)

Run instnamer on test. Also can be merged

30 ↗(On Diff #104312)

Drop extra string attributes

34 ↗(On Diff #104312)

Drop all metadata

cfang updated this revision to Diff 104503.Jun 28 2017, 2:04 PM

Update based on Matt's review.

For the test:

  1. need details on how to change to a kernel, especially what the argument should be.
    • I tried a few options, but it seems we could not reproduce the issue with the kernel version, possibly because code is optimized away.
  1. not clear what to merge!
arsenm added inline comments.Jul 21 2017, 4:36 PM
test/CodeGen/AMDGPU/vgpr-to-sgpr-phi.ll
7 ↗(On Diff #104503)

Does it still reproduce if you make it a kernel?

7–9 ↗(On Diff #104312)

It can merge into one of the other test files for this pass

cfang added inline comments.Jul 24 2017, 10:03 AM
test/CodeGen/AMDGPU/vgpr-to-sgpr-phi.ll
7 ↗(On Diff #104503)

The issue is not reproducible if I make it a kernel.

7–9 ↗(On Diff #104312)

Can you be more specific which test should I merge to? It is not clear to me which tests are for this pass (simply guess from the names).
If I place an assert in the place I am working on, I saw more than twenty tests failures.

Which test is for the following piece of code?

// We don't need to fix the PHI if the common dominator of the
// two incoming blocks terminates with a uniform branch.
if (MI.getNumExplicitOperands() == 5) {
  MachineBasicBlock *MBB0 = MI.getOperand(2).getMBB();
  MachineBasicBlock *MBB1 = MI.getOperand(4).getMBB();

  if (!predsHasDivergentTerminator(MBB0, TRI) &&
      !predsHasDivergentTerminator(MBB1, TRI)) {
    DEBUG(dbgs() << "Not fixing PHI for uniform branch: " << MI << '\n');
    break;
  }
}
cfang updated this revision to Diff 108496.Jul 27 2017, 10:00 AM

Merge the test into uniform-cfg.ll.

I can not find an approach to change the test to a kernel and yet still be able to reproduce the issue.
So I think it is OK to use a function here.

cfang added a comment.Aug 1 2017, 3:43 PM

Ping! Thanks.

arsenm accepted this revision.Aug 2 2017, 2:31 PM

LGTM

This revision is now accepted and ready to land.Aug 2 2017, 2:31 PM
This revision was automatically updated to reflect the committed changes.