[PATCH] D136892: [AMDGPU] Unify uniform return and divergent unreachable blocks

Brendon Cahoon via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 27 15:18:51 PDT 2022


bcahoon created this revision.
bcahoon added reviewers: ruiling, arsenm.
Herald added subscribers: kosarev, foad, kerbowa, hiraditya, t-tye, tpr, dstuttard, yaxunl, jvesely, kzhuravl.
Herald added a project: All.
bcahoon requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

This patch fixes a failed to annotate CFG error in
SIAnnotateControlFlow. The error indicates that the CFG is not
structurized.

The problem occurs when there are divergent unreachable blocks
and uniform return blocks in the same region. In this case,
AMDGPUUnifyDivergentExitNodes does not create a unified block so
the region contains multiple exits.

StructurizeCFG does not work properly when there are multiple
exits, so the necessary CFG transformations do not occur along
divergent control flow paths.

Subsequently, SIAnnotateControlFlow processes the paths to
divergent unreachable blocks, but may only partially process
blocks along a uniform control flow path to the return block.

This patch fixes the bug by creating a single exit block when
there is uniform return block and divergent unreachable blocks
in the same region. When the region contains a single exit,
then StructurizeCFG and SIAnnotateControlFlow transform the
CFG correctly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136892

Files:
  llvm/lib/Target/AMDGPU/AMDGPUUnifyDivergentExitNodes.cpp
  llvm/test/CodeGen/AMDGPU/si-unify-exit-return-unreachable.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136892.471305.patch
Type: text/x-patch
Size: 12736 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221027/7ad7eb65/attachment.bin>


More information about the llvm-commits mailing list