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

via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 14 20:26:43 PST 2024


modiking wrote:

>Oh, the docs also say "#pragma unroll and #pragma unroll value have identical semantics to #pragma clang loop unroll(full) and #pragma clang loop unroll_count(value) respectively. " - so that doesn't sound like #pragma clang loop unroll(full) would help the situation?

Oh interesting, I was't quite certain myself on what the exact semantics are. Thanks for digging it up.

>The condition that was added in this patch that seems to be relevant, if I'm understanding correctly, is to add UP.Count < TripCount as a condition to bailout/abort all the unrolling, if the trip count exceeds the count on the unroll pragma, I guess?

The way the code is structured is that the unroll trip count is either stored in `TripCount` or in `MaxTripCount` depending on how it was calculated. Before, only checking against `MaxTripCount` would cause `#pragma clang loop unroll(full)` to also perform partial unrolling under `-loop-unroll-full`.

Actually, I wonder if that's what causing the change where previously it would try and do a partial unroll but that no longer happens. What's the output with `-debug-only=loop-unroll`?

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


More information about the llvm-commits mailing list