This is an archive of the discontinued LLVM Phabricator instance.

[LoopUnroll] Reset PeelCount on exit before computePeelCount.
Needs ReviewPublic

Authored by fhahn on May 17 2020, 6:45 AM.

Details

Reviewers
efriedma
hfinkel
Summary

Currently UP.PeelCount can be set by either TTI or -unroll-peel-count,
before computePeelCount is actually called. computePeelCount also checks
if the loop can be peeled and if we exit before calling it, the
PeelCount is set regardless whether the loop can be peeled or not.

If we exit before computePeelCount, we should set the PeelCount to 0.
Alternatively we could also just check if the loop is peel-able in
peelLoop(), but I think it is reasonable for the caller to ensure that
it is only called with peel-able loops. We could also call
computePeelCount, instead of setting it to zero, in case PeelCount != 0.
But that's probably worth doing as a follow-up.

Note that now it is not possible to combine peeling and unrolling in the
same step using LoopUnrollPass I think, hence the test changes.

Diff Detail

Event Timeline

fhahn created this revision.May 17 2020, 6:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 17 2020, 6:45 AM

If there are separate values "desired peel count" and "actual number of times we've decided to peel", I'd prefer to store them in separate variables; resetting the peel count like this seems overly complicated.

Note that now it is not possible to combine peeling and unrolling in the same step using LoopUnrollPass I think, hence the test changes.

Do we want to allow this? It seems reasonable to both peel and partially unroll a loop, although we probably want compute the unrolll cost on the peeled loop.

If there are separate values "desired peel count" and "actual number of times we've decided to peel", I'd prefer to store them in separate variables; resetting the peel count like this seems overly complicated.

yeah, it would be cleaner to have 2 variables. I'll update the patch.

Note that now it is not possible to combine peeling and unrolling in the same step using LoopUnrollPass I think, hence the test changes.

Do we want to allow this? It seems reasonable to both peel and partially unroll a loop, although we probably want compute the unrolll cost on the peeled loop.

Currently we mostly peel if it simplifies a condition in the body, which would make sense to combine with partial unrolling. I think computing the unroll cost on the peeled loop might require some more work given he current code structure, but it would be an interesting follow-up.