[LoopUnroll] Remove `computeUnrollCount()`'s return value (#184529)
`computeUnrollCount()`'s return value is used to communicate whether
unrolling was explicitly requested. However, each of
`computeUnrollCount()`'s two callers can compute this directly:
- `LoopUnrollAndJamPass` already checks for loop unrolling metadata
[before calling
`computeUnrollCount()`](https://github.com/llvm/llvm-project/blob/43dbcdea98f5bb04ae967bdd81ece2d2144f4661/llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp#L308).
The return value only added handling for `-unroll-count`, a testing flag
with no UnrollAndJam test coverage.
- `tryToUnrollLoop()` can use `PragmaInfo(L).ExplicitUnroll` directly at
the `setLoopAlreadyUnrolled()` call site.
- In all but one case where `computeUnrollCount()` explicitly `return`s
`false` instead of `ExplicitUnroll`, `UP.Count = 0` is set. This causes
`tryToUnrollLoop()` to early-exit before reaching
`setLoopAlreadyUnrolled`.
- The remaining case that `return`s false, but does not set `UP.Count =
0` [seems to be a
bug](https://github.com/llvm/llvm-project/pull/184529#discussion_r2893041263).
I'm in the process of addressing that with #185979.
- On all remaining paths, the return value is equivalent to
`UnrollPragmaInfo(L).ExplicitUnroll`.
IMHO, this is a small step toward simplifying the loop-unrolling
heuristics by making `computeUnrollCount()` slightly easier to read.
GitOrigin-RevId: c9a2f0b72c08c4ead0d359b2d7aa7ea34708cc5a
5 files changed