This patch reworks the fix from D20627 "Do not rename registers that do
not start an independent live range". That fix depended on the scheduler
dependency graph having redundant edges. Those edges are removed by
D156552 "[MachineScheduler] Track physical register dependencies
per-regunit" with the result that on several Hexagon lit tests, the
post-RA scheduler would schedule the code in a way that fails machine
verification.
Consider this code where D11 is a pair R23:R22:
SU(0): %R2<def> = A2_add %R23, %R17<kill> (anti dependency on R23 here) SU(8): %R23<def> = S2_asr_i_r %R22, 31 (data dependency on R23->D11 here) SU(10): %D0<def> = A2_tfrp %D11<kill>
The original fix would detect this situation by examining the dependency
from SU(8) to SU(10) and seeing that D11 is not a subreg of R23.
A slightly more complicated example:
SU(0): %R2<def> = A2_add %R23, %R17<kill> (anti dependency on R23 here) SU(8): %R23<def> = S2_asr_i_r %R22, 31 (data dependency on R23 here) SU(9): %R23<def> = S2_asr_i_r %R23, 31 (data dependency on R23->D11 here) SU(10): %D0<def> = A2_tfrp %D11<kill>
The original fix also worked on this example, but only because
ScheduleDAGInstrs adds an extra data dependency edge directly from SU(8)
to SU(10). This edge is redundant, since you could infer it transitively
from the edges SU(8)->SU(9) and SU(9)->SU(10), and since none of the
data that SU(8) writes to R23 is read by SU(10).
After D156552 the redundant edge SU(8)->SU(10) will not be present, so
when we examine the successors of SU(8) we will not find any that read
from a superreg of R23.
This patch removes the original fix from D20627, which examined edges in
the dependency graph. Instead it extends a check that was already being
done in FindSuitableFreeRegisters: instead of checking that *some*
register is a superreg of all registers in the rename group, we now
check that the specific register that carries the anti-dependency that
we want to break is a superreg of all registers in the rename group.
use Register instead of unsigned