Trip count computation during epilog vectorization

We are caching TripCount of a loop in “EpilogueLoopVectorizationInfo.TripCount” during first pass ( Main Loop) vectorization. I see we use the cached value at “emitMinimumVectorEpilogueIterCountCheck” during the second pass( Epilog Vector loop).

–Snip–
BasicBlock *
EpilogueVectorizerEpilogueLoop::emitMinimumVectorEpilogueIterCountCheck(
Loop *L, BasicBlock *Bypass, BasicBlock *Insert) {

assert(EPI.TripCount &&
“Expected trip count to have been safed in the first pass.”);
assert(
(!isa(EPI.TripCount) ||
DT->dominates(cast(EPI.TripCount)->getParent(), Insert)) &&
“saved trip count does not dominate insertion point.”);
Value *TC = EPI.TripCount;
–Snip–

Can that be used in other places also in second pass? (TripCount = EPI.TripCount). In the trunk I see we are recomputing again via getOrCreateTripCount(L) during the second pass (Epilog vector loop)
is it guaranteed that trip count will always dominate the epilog vector loop and scalar loop ?

how to reproduce your issue?

I think in current main it should reuse the already computed trip count. The expression for the trip count should be expanded in the first vector pre header block, dominating all blocks created by the vectorizer.