This is an archive of the discontinued LLVM Phabricator instance.

AMDGPU: Fix SI_IF lowering when the save exec reg has terminator uses
ClosedPublic

Authored by arsenm on Dec 27 2019, 10:43 AM.

Details

Summary

Reverts part of 6524a7a2b9ca072bd7f7b4355d1230e70c679d2f. Since that
commit, the expansion was ignoring the actual save exec register
produced by the instruction, and looking at other instructions. I do
not understand why it was looking at other instructions, but relying
on this scan was wrong.

Fixes verifier errors after SI_IF is tail duplicated, which should be
correct to do. The results were fed into a phi, which was lowered to
the S_MOV_B64_term instructions.

Diff Detail

Event Timeline

arsenm created this revision.Dec 27 2019, 10:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 27 2019, 10:43 AM
nhaehnle accepted this revision.Jan 30 2020, 1:58 AM

This seems like a reasonable change. The purpose of getSaveExec should have been better explained in a comment. LGTM.

This revision is now accepted and ready to land.Jan 30 2020, 1:58 AM

As far as I remember the origin of this hack:

PHI elimination pass queries isTerminator() to determine the COPY insertion point.
For some reason SI_IF is terminator but produces the value that in order may be input to the PHI node.
The hackery mentioned above was added to cheat verifier that complained about the non term instruction after the terminator.
The getSaveExec redirects the caller from SI_IF operand 0 to S_MOV_* destination operand.
That relies on the fact that the only reason for such a S_MOV_* to exist after SI_IF is the use of the SI_IF result in the successor block.

As for the current change: if everything works w/o the hack - then it's great to delete it.