[llvm] [LoopUnroll] Enable allowexpensivetripcounts when user provides pragma (PR #181267)

Adel Ejjeh via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 9 08:30:26 PDT 2026


adelejjeh wrote:

@nikic I've updated the PR with a revised approach based on your feedback. Instead of setting `AllowExpensiveTripCount` and `Runtime` in `computeUnrollCount()`, I moved them into `gatherUnrollingPreferences()` before the TTI call, conditioned on `PragmaEnableUnroll || PragmaCount > 0` (excluding `PragmaFullUnroll` as you suggested). This lets targets naturally opt out by overriding `AllowExpensiveTripCount` in their `getUnrollingPreferences()`. I added explicit opt-outs for all non-AMDGPU targets so existing behavior is preserved — target maintainers can remove the opt-out to pick up the new behavior when they're ready. The `shouldPragmaUnroll()` path still sets `AllowExpensiveTripCount` for `UserUnrollCount || PragmaCount > 0` to preserve `-unroll-count` behavior. Lit tests pass with these changes. Would appreciate your thoughts on this approach when you get a chance.


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


More information about the llvm-commits mailing list