Thank you both for your comments. I have added the check to ensure the index vector won't cause an overflow. I also added tests to the testsuite in order to check that the loop is vectorized for UINT_MAX - 1 iterations but not UINT_MAX iterations. I was not able to write code that triggers INTEGER_INDUC_COND_REDUCTION when using char or other smaller types (changing the types of last, min_v and a to something else causes COND_REDUCTION to be used instead), so these tests are only compiled and not executed. I also moved an instruction that generates a vector of zeroes (used for COND_REDUCTION) in the branch of code run only for COND_REDUCTION, this should remove the unused vector that Alan noticed. 2017-11-21 Kilian Verhetsel gcc/ChangeLog: PR testsuite/81179 * tree-vect-loop.c (vect_create_epilog_for_reduction): Fix the returned value for INTEGER_INDUC_COND_REDUCTION whose last match occurred at index 0. (vectorizable_reduction): For INTEGER_INDUC_COND_REDUCTION, pass the PHI statement that sets the induction variable to the code generating the epilogue and check that no overflow will occur. gcc/testsuite/ChangeLog: * gcc.dg/vect/vect-iv-cond-reduc-overflow-1.c: New test for overflows when compiling conditional reductions. * gcc.dg/vect/vect-iv-cond-reduc-overflow-2.c: Likewise.