R600/SI: Adjsut SGPR live ranges before register allocation
authorTom Stellard <thomas.stellard@amd.com>
Wed, 2 Jul 2014 20:53:48 +0000 (20:53 +0000)
committerTom Stellard <thomas.stellard@amd.com>
Wed, 2 Jul 2014 20:53:48 +0000 (20:53 +0000)
commitb48c8c49d5b578dccd8debc03eb0b893e8ac06d2
tree08d3701c5263e3c3db269377169352f239858c56
parenta75d388f18cde0068b0623dcbbfa954ffc8baf66
R600/SI: Adjsut SGPR live ranges before register allocation

SGPRs are written by instructions that sometimes will ignore control flow,
which means if you have code like:

if (VGPR0) {
  SGPR0 = S_MOV_B32 0
} else {
  SGPR0 = S_MOV_B32 1
}

The value of SGPR0 will 1 no matter what the condition is.

In order to deal with this situation correctly, we need to view the
program as if it were a single basic block when we calculate the
live ranges for the SGPRs.  They way we actually update the live
range is by iterating over all of the segments in each LiveRange
object and setting the end of each segment equal to the start of
the next segment.  So a live range like:

[3888r,9312r:0)[10032B,10384B:0)  0@3888r

will become:

[3888r,10032B:0)[10032B,10384B:0)  0@3888r

This change will allow us to use SALU instructions within branches.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212215 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/R600/AMDGPU.h
lib/Target/R600/AMDGPUTargetMachine.cpp
lib/Target/R600/CMakeLists.txt
lib/Target/R600/SIFixSGPRLiveRanges.cpp [new file with mode: 0644]