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

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

DebugLocs are supposed to be passed by reference now

2291

Period

2299–2306

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

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
1013–1016

Extra space here

1018–1021

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.