llvm vectorizer will vectorize loop when loop iteration numbers are unknown. When the iteration number of a loop is very small and the preparation and rounding-off cost for vectorization is high, such vectorization may degrade performance, sometimes significantly. We find gcc vectorization generates runtime check to ensure loop iteration number is big enough before every vectorized loop.
Now llvm loop vectorizer generates overflow check before every vectorized loop. The overflow check is to check whether BackedgeCount equals to -1, .i.e ExitCount equals to 0. If the return of the check is true, jump to scalar remainder loop. This check can be covered by the minimum loop iterations check, because if overflow happens, the ExitCount number will be 0 and it will be less than the minimum loop iterations threshold.
This patch turns the original overflow check to a minimum loop iterations check, which has no change on correctness and runtime cost, and can be beneficial for performance in some cases.
The second paragraph is unnecessarily complicated. It should say something like this:
The minimum iteration check also covers case where the backedge-taken count is uint##_max. Adding one to it will cause overflow and an incorrect loop trip count being generated in the vector body. In this case we also want to directly jump to the scalar remainder loop.