[llvm] [SimpleLoopUnswitch] Don't latch-redirect trivial unswitch across convergent ops (PR #207047)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 1 23:55:56 PDT 2026


================
@@ -549,6 +549,19 @@ static Loop *getTopMostExitingLoop(const BasicBlock *ExitBB,
   return TopMost;
 }
 
+/// Check if a loop contains convergent or token operations.
+static bool loopContainsConvergentOrTokenOp(const Loop &L) {
+  for (const auto *BB : L.blocks())
+    for (const auto &I : *BB) {
+      if (I.getType()->isTokenTy() && I.isUsedOutsideOfBlock(BB))
+        return true;
+      if (const auto *CB = dyn_cast<CallBase>(&I))
+        if (CB->isConvergent())
+          return true;
+    }
+  return false;
----------------
arsenm wrote:

The convergence control intrinsics return tokens 

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


More information about the llvm-commits mailing list