[PATCH] D102982: [LoopUnroll] Use smallest exact trip count from any exit

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 26 11:42:41 PDT 2021


reames added a comment.

In D102982#2782815 <https://reviews.llvm.org/D102982#2782815>, @nikic wrote:

> I just realized what I was confused about in the first place: `getBackedgeTakenCount()` requires that **all** exits have an exact exit count. If you have one unpredicate exit and one exit with an exact exit count, then you'll get back an unpredictable backedge taken count. Only if all exits have an exact exit count will the umin be taken. (This is the `isComplete()` condition in `BackedgeTakenInfo::getExact()`.)

I think you've returned to an earlier confusion.  I don't remember if this was from this review, or another recent one.

What unrolling appears to want here is a *maximum* trip count.  What it's actually computing is an *exact* trip count.  The variable names are highly confusing.  I had previously suggested you rename all the TripCount variables to MaxTripCount and use the appropriate means to query that upper bound.

Specifically:
SE.getTripCountFromExitCount(SE.getConstantMaxBackedgeTakenCount(L))

I repeat that suggestion.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102982/new/

https://reviews.llvm.org/D102982



More information about the llvm-commits mailing list