[llvm] [LoopUnroll] Allow runtime unroll with remainder for uniform trip count in convergent loops (PR #192819)

Luo Yuanke via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 23 05:45:47 PDT 2026


================
@@ -1371,9 +1396,8 @@ tryToUnrollLoop(Loop *L, DominatorTree &DT, LoopInfo *LI, ScalarEvolution &SE,
   // to do the first few instructions before we hit the unrolled loop
   // is unsafe -- it adds a control-flow dependency to the convergent
   // operation.  Therefore restrict remainder loop (try unrolling without).
-  //
-  // TODO: This is somewhat conservative; we could allow the remainder if the
-  // trip count is uniform.
+  // This is already accounted for in UCE.ConvergenceAllowsRuntime, which
+  // also considers whether the trip count is uniform across all threads.
----------------
LuoYuanke wrote:

I move the comments about uniformity to the code place where UCE.ConvergenceAllowsRuntime is initialized.

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


More information about the llvm-commits mailing list