This is an archive of the discontinued LLVM Phabricator instance.

AMDGPU/SI: Avoid creating unnecessary copies in the SIFixSGPRCopies pass
ClosedPublic

Authored by tstellarAMD on Aug 11 2016, 9:25 AM.

Details

Summary
  1. Don't try to copy values to and from the same register class.
  2. Replace copies with of registers with immediate values with v_mov/s_mov instructions.

The main purpose of this change is to make MachineSink do a better job of
determining when it is beneficial to split a critical edge, since the pass
assumes that copies will become move instructions.

This prevents a regression in uniform-cfg.ll if we enable critical edge
splitting for AMDGPU.

Diff Detail

Repository
rL LLVM

Event Timeline

tstellarAMD retitled this revision from to AMDGPU/SI: Avoid creating unnecessary copies in the SIFixSGPRCopies pass.
tstellarAMD updated this object.
tstellarAMD added a reviewer: arsenm.
tstellarAMD added a subscriber: llvm-commits.
arsenm added inline comments.Aug 11 2016, 10:19 AM
lib/Target/AMDGPU/SIInstrInfo.cpp
2289 ↗(On Diff #67695)

DebugLocs are supposed to be passed by reference now

2291 ↗(On Diff #67695)

Period

2299–2306 ↗(On Diff #67695)

There are two different ways here of referring to the same, original value. It would be easier to follow if Op.getReg() was assigned to a variable at the beginning, and then consistently used instead of switching to Copy->getOperand(1).getReg(), and then you wouldn't need to worry about the order of the Op.setReg().

Could Op have a sub register index?

2755 ↗(On Diff #67695)

You can use Inst.isCopy()

tstellarAMD marked 4 inline comments as done.

Address review comments and rebase.

arsenm accepted this revision.Sep 6 2016, 4:12 PM
arsenm edited edge metadata.

LGTM

lib/Target/AMDGPU/SIRegisterInfo.cpp
1000 ↗(On Diff #70448)

Extra space here

1005–1007 ↗(On Diff #70448)

This should be inline in the header and be isVGPRReg to match the existing isSGPRReg (or that should have the Reg part removed)

This revision is now accepted and ready to land.Sep 6 2016, 4:12 PM

Looks like patch was not committed.

This revision was automatically updated to reflect the committed changes.