This is an archive of the discontinued LLVM Phabricator instance.

[LoopUnroll] Modify a comment to clarify the usage of TripCount. NFC.
ClosedPublic

Authored by haicheng on Nov 15 2016, 8:05 AM.

Details

Summary

Per the request of Evgeny, I add a few sentences in the comments to clarif when TripCount contains the upper bound value.

Diff Detail

Repository
rL LLVM

Event Timeline

haicheng updated this revision to Diff 78003.Nov 15 2016, 8:05 AM
haicheng retitled this revision from to [LoopUnroll] Modify a comment to clarify the usage of TripCount. NFC..
haicheng updated this object.
haicheng added reviewers: mzolotukhin, evstupac.
haicheng set the repository for this revision to rL LLVM.
haicheng added a subscriber: llvm-commits.

Hi Evgeny,

Would you please take a look at what I modified? Please let me know if it is what you want.

Thank you,

Haicheng

mzolotukhin edited edge metadata.Nov 30 2016, 2:14 PM

Hi Haicheng,

The comment is still confusing, at least to me. For instance, this sentence:

... Parameter TripCount
may contain the exact number or the upper bound.

repeats what we've said in:

... In other words, control may exit the loop prior to TripCount 
iterations via an early branch, but control may not exit the loop from the
LatchBlock's terminator prior to TripCount iterations.

At least, it looks very much the same.

AFAIU, now we started to handle cases where the loop may exit from the LatchBlock's terminator prior to TripCount iterations - am I right here? If so, can we somehow reflect it in the comment (maybe reword it entirely)?

Thanks,
Michael

AFAIU, now we started to handle cases where the loop may exit from the LatchBlock's terminator prior to TripCount iterations - am I right here? If so, can we somehow reflect it in the comment (maybe reword it entirely)?

You are absolutely correct. Let me try to rephrase it. Do you have any suggestions?

Thanks,

Haicheng

How about rewriting the whole paragraph as this?

TripCount is the upper bound of the iteration on which control exits LatchBlock. Control may exit the loop prior to TripCount iterations either via an early branch of other loop block or via LatchBlock terminator. This is relaxed from the general definition of trip count which is the number of times the loop header executes. Note that UnrollLoop assumes that the loop counter test is in LatchBlock in order to remove unnecesssary instances of the test.

haicheng updated this revision to Diff 80764.Dec 8 2016, 9:05 AM
haicheng edited edge metadata.

Rewrite the comment paragraph. Hopefully, it is more clear.

mzolotukhin accepted this revision.Dec 14 2016, 4:48 PM
mzolotukhin edited edge metadata.

Yes, it looks better now.

Thank you,
Michael

This revision is now accepted and ready to land.Dec 14 2016, 4:48 PM
This revision was automatically updated to reflect the committed changes.