[llvm] [LoopUnroll] Bound automatic full-unroll cloning work (PR #211683)

Justin Fargnoli via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 29 20:15:28 PDT 2026


================
@@ -918,6 +926,19 @@ static std::optional<unsigned> shouldFullUnroll(
   // When computing the unrolled size, note that BEInsns are not replicated
   // like the rest of the loop body.
   uint64_t UnrolledSize = UCE.getUnrolledLoopSize(UP, FullUnrollTripCount);
+  uint64_t LoopInstructionCount = 0;
+  for (const BasicBlock *BB : L->blocks())
+    LoopInstructionCount += BB->size();
+  uint64_t AdditionalCopies = FullUnrollTripCount - 1;
+  if (!ExplicitUnroll && UP.Threshold != NoThreshold && AdditionalCopies &&
----------------
justinfargnoli wrote:

> shouldPragmaUnroll does not cover #pragma unroll(enable) with a known trip count (it only handles the upper-bound case when !TripCount);

If the behavior here should be different, then let's fix that in `shouldPragmaUnroll` in a separate patch. 

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


More information about the llvm-commits mailing list