Fix PR51084: #pragma unroll aggressively increases UP.Threshold from (150
for -O2 and 300 for -O3) to 16384. This is usually undesired. Just double the
thresholds.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Event Timeline
I'm not really sold on this. I suspect the fix should either be in LSR, or perhaps it's working as intended.
I guess the main problem is - is there proper documentation for #pragma clang loop unroll(enable)?
I agree with Roman, this does not seem obvious. The bug seems to be either a) an issue with LSR, or b) invalid (e.g. we obeyed a user directive which was a poor choice - but not our choice).
I agree. I wasn't aware of the semantics of unroll pragmas.
LangRef: "This metadata suggests that the loop should be fully unrolled if the trip count is known at compile time and partially unrolled if the trip count is not known at compile time."
https://clang.llvm.org/docs/LanguageExtensions.html#loop-unrolling : "If unroll(enable) is specified the unroller will attempt to fully unroll the loop if the trip count is known at compile time."
"If unroll(full) is specified the unroller will attempt to fully unroll the loop if the trip count is known at compile time identically to unroll(enable)."
Full unrolling does what the user asks, even though such a large trip count may look silly.