- Where SIFixWWMLiveness adds dummy operands to EXIT_WWM, remove kill
marks from other uses of the same register to avoid the MIR becoming
invalid.
- SIFixWWMLiveness's scheme for finding registers that might be live in
disabled lanes at the point of the WWM code involves finding defs that
reach the WWM code, and would be considered live if all defs are
considered partial defs.
That scheme could find false positives in defs that do not dominate the
WWM code, and thus do not really have a live value reaching it in any
lane. The two problems with adding a dummy operand for such a register
to EXIT_WWM are (a) it is over-conservative, and (b) it violates
MachineVerifier's check that all uses are fully defined, even if
sometimes by an IMPLICIT_DEF that arises from a undef phi input.
This commit fixes it by only considering defs that dominate the
EXIT_WWM.
Change-Id: I3d70f6138798c3aaa8b6bdf290d4eb85c7beb311
Unfortunately, this won't work in general. Consider something like:
The definition of foo doesn't dominate the WWM instructions earlier in the loop body, but the use of foo can potentially "see" the result of many different iterations of the loop, since the loop trip count is non-uniform, and any WWM instructions will clobber everything but the last iteration. Hence we need to add an artificial interference with foo here. Of course, if you removed the use of foo outside the loop, then we wouldn't need to do anything... it's the actual use that is crucial here.
We also ran into the issue of SIFixWWMLiveness being too conservative (as well as the liveness issue) when enabling AMD_shader_ballot for radv, but I haven't been able to come up with a good solution for it. It seems that we have to treat loops, and registers live out of a loop, specially somehow.