[llvm] [Analysis] Ignore convergence tokens in dead branches in `CodeMetrics` (PR #193590)

Deric C. via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 23 11:53:33 PDT 2026


================
@@ -118,7 +119,12 @@ static bool extendsConvergenceOutsideLoop(const Instruction &I, const Loop *L) {
   if (!isa<ConvergenceControlInst>(I))
     return false;
   for (const auto *U : I.users()) {
-    if (!L->contains(cast<Instruction>(U)))
+    const auto *UserInst = cast<Instruction>(U);
+    // Ignore users in dead branches, identified by blocks terminated with
+    // unreachable.
+    if (isa<UnreachableInst>(UserInst->getParent()->getTerminator()))
----------------
Icohedron wrote:

It is "a common method to determine if the branch is unreachable", but not a the method to determine if the branch is dead. Yet your code comment says "dead branches". 
Blocks terminated with an unreachable are not necessarily dead branches.

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


More information about the llvm-commits mailing list