This is an archive of the discontinued LLVM Phabricator instance.

AMDGPU/GlobalISel: Fix masked control flow with fallthrough blocks
ClosedPublic

Authored by arsenm on May 17 2020, 12:53 PM.

Details

Summary

Unlike SelectionDAGBuilder, IRTranslator omits the unconditonal branch
in fallthrough cases. Confusingly, the control flow pseudos function
in the opposite way the intrinsics are used, and the branch targets
always need to be swapped. We're inverting the target blocks, so we
need to figure out the old fallthrough block and insert a branch to
the original unconditional branch target.

Diff Detail

Event Timeline

arsenm created this revision.May 17 2020, 12:53 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 17 2020, 12:53 PM

I think the patch is okay, but have a couple of doubts about the tests.

llvm/test/CodeGen/AMDGPU/GlobalISel/divergent-control-flow.ll
40

For this and all other similar updates, does this mean that the existing testcases were actually wrong?

llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-brcond.mir
232

"backward" is a bit of an understatement when describing this very interesting artifact. I don't know the SI intrinsics very well, but the name suggests it should be a backedge. But this use suggests that the meaning is more general than that: the presence of SI_LOOP instead of a simple conditional branch indicates that the edge is either a backedge or a loop exit.

arsenm marked 2 inline comments as done.May 22 2020, 5:54 AM
arsenm added inline comments.
llvm/test/CodeGen/AMDGPU/GlobalISel/divergent-control-flow.ll
40

Yes

llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-brcond.mir
232

Yes, I've been confused by this every time I've ever looked at this. If you look at how SI_LOOP is lowered, it's the s_cbranch_execnz which should be the backedge, but the loop intrinsic on return true exits the loop

sameerds accepted this revision.May 22 2020, 7:18 AM

LGTM!

This revision is now accepted and ready to land.May 22 2020, 7:18 AM