[PATCH] D136892: [AMDGPU] Unify uniform return and divergent unreachable blocks
Ruiling, Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 31 08:23:58 PDT 2022
ruiling added inline comments.
================
Comment at: llvm/lib/Target/AMDGPU/AMDGPUUnifyDivergentExitNodes.cpp:224
UnreachableBlocks.push_back(BB);
+ HasDivergentUnreachableBlocks |= !isUniformlyReached(DA, *BB);
} else if (BranchInst *BI = dyn_cast<BranchInst>(BB->getTerminator())) {
----------------
I think the key point is we need to make sure to unify the function exits if there is any divergent branch to make sure the structurizer is not skipped when needed. The change does not work if there are both divergent reached return block and uniformly reached return block (no unreachable block). In this case, we still need to unify both the uniform/divergent return blocks. So, I would suggest you change to something like below:
```
scanning the terminators of all the blocks in the function,
if there is any divergent branch, set HasDivergentBranch to true.
then:
if (!HasDivergentBranch && isUniformlyReached(DA, *BB))
ReturningBlocks.push_back(BB);
It is also preferred to process unreachable blocks in the same way:
if (!HasDivergentBranch && isUniformlyReached(DA, *BB))
UnreachableBlocks.push_back(BB);
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D136892/new/
https://reviews.llvm.org/D136892
More information about the llvm-commits
mailing list