[llvm] [LoopUnroll] Introduce UnrollMaxIterations as a hard cap on how many iterations we try to unroll (PR #78648)

via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 2 11:53:33 PST 2024


modiking wrote:

@nikic Hmm interesting enough it's still trying to partially unroll with `-loop-unroll-full`. Looking into it more, this condition isn't bailing out:
```
  // Do not attempt partial/runtime unrolling in FullLoopUnrolling
  if (OnlyFullUnroll && !(UP.Count >= MaxTripCount)) {
    LLVM_DEBUG(
        dbgs() << "Not attempting partial/runtime unroll in FullLoopUnroll.\n");
    return LoopUnrollResult::Unmodified;
  }
 ```
 
Because TripCount == 2147483648 so MaxTripCount == 0 while partial unroll sets UP.Count == 2048. Scanning through I think we should also catch this case and add a check for `UP.Count < TripCount`. WDYT?

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


More information about the llvm-commits mailing list