This is an archive of the discontinued LLVM Phabricator instance.

AMDGPU/SI: add llvm.amdgcn.ps.live intrinsic
ClosedPublic

Authored by nhaehnle on Apr 16 2016, 11:00 AM.

Details

Summary

This intrinsic returns true if the current thread belongs to a live pixel
and false if it belongs to a pixel that we are executing only for derivative
computation. It will be used by Mesa to implement gl_HelperInvocation.

Note that for pixels that are killed during the shader, this implementation
also returns true, but it doesn't matter because those pixels are always
disabled in the EXEC mask.

This unearthed a corner case in the instruction verifier, which complained
about a v_cndmask 0, 1, exec, exec<imp-use> instruction. That's stupid but
correct code, so make the verifier accept it as such.

Diff Detail

Repository
rL LLVM

Event Timeline

nhaehnle updated this revision to Diff 53991.Apr 16 2016, 11:00 AM
nhaehnle retitled this revision from to AMDGPU/SI: add llvm.amdgcn.ps.live intrinsic.
nhaehnle updated this object.
nhaehnle added reviewers: arsenm, tstellarAMD.
nhaehnle added a subscriber: llvm-commits.
arsenm edited edge metadata.Apr 16 2016, 1:11 PM

Is this just a read from the exec mask? It should probably be convergent. Can you accomplish the same thing with a convergent call to the read_register intrinsic?

I don't think it should be convergent, because other threads in the wave do not affect the return value. It does have to be a source of divergence, though.

I didn't consider the possibility of reading from the EXEC mask, but it's tricky. The intrinsic must return the initial EXEC mask. In a pixel shader, the current EXEC mask can be a superset of the initial EXEC. Even if Mesa always emits the intrinsic call as the first thing in the shader, I don't think we can/should rely on the various scheduler steps in LLVM maintaining that ordering.

Ping - is this good to go?

tstellarAMD accepted this revision.Apr 21 2016, 6:16 PM
tstellarAMD edited edge metadata.

This looks OK.

This revision is now accepted and ready to land.Apr 21 2016, 6:16 PM
This revision was automatically updated to reflect the committed changes.