[llvm] [AMDGPU] Add islands to StructurizeCFG (PR #201675)

Robert Imschweiler via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 27 00:19:56 PDT 2026


================
@@ -59,6 +62,36 @@ using namespace llvm::PatternMatch;
 // The name for newly created blocks.
 const char FlowBlockName[] = "Flow";
 
+/// True if BB contains nothing but an unconditional branch and has only one
+/// predecessor.
+static bool isIntermediateTarget(const BasicBlock &BB) {
+  return BB.size() == 1 && isa<UncondBrInst>(BB.getTerminator()) &&
+         BB.getUniquePredecessor();
+}
+
+/// True if BB's terminator must be preserved verbatim and therefore cannot
+/// serve as a rewritable flow tail (it can be neither killed nor have its
+/// successors rewritten). Currently only callbr.
+static bool isIsland(const BasicBlock *BB) {
+  return isa<CallBrInst>(BB->getTerminator());
----------------
ro-i wrote:

Since this PR builds the base for all "multi-branch" constructs, it should not be that hard to make work, ig. But I feel like this is out-of-scope for this PR at the moment

https://github.com/llvm/llvm-project/pull/201675


More information about the llvm-commits mailing list