[PATCH] D34150: [LV] Test once if vector trip count is zero, instead of twice
Ayal Zaks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 13 09:00:59 PDT 2017
Ayal created this revision.
Herald added a subscriber: mzolotukhin.
Before reaching the header block of the vectorized loop, the Loop Vectorizer generates two conditions to make sure the vectorized loop will iterate at-least once: first emitVectorLoopEnteredCheck() compares the Scalar Trip Count to VF*UF, and if the former is not less than the latter, emitMinimumIterationCountCheck() compares the Vector Trip Count to zero.
In general, VTC = STC mod VF*UF, unless this does not comply with an optional constraint to execute at-least a single scalar iteration in the epilog, aka requiresScalarEpilogue(). In this case a single (the last) vector iteration is peeled and replaced with VF*UF scalar iterations (instead of none), reducing VTC by 1.
This patch replaces the above two comparisons for VTC == 0 with a single comparison:
- STC < VF*UF, when requiresScalarEpilogue() does not hold; or
- STC <= VF*UF, when requiresScalarEpilogue() does hold,
effectively removing the basic-block originally named "min.iters.checked".
The original documentation of emitMinimumIterationCountCheck() claiming it checks for overflow seems obsolete (right?).
Original observation and initial patch by Evgeny Stupachenko.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 21240 bytes
Desc: not available
More information about the llvm-commits