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.
Please don't remove the explanation for the need of checking overflow.
I like your explanation in the review description. Please include an appropriate variant of that here as a comment.