Previous patch exposes another issue with the code - LOOP_VINFO_INT_NITERS is already adjusted for prologue peeling.
Bootstrap and regtest running on x86_64-unknown-linux-gnu. Richard. 2018-12-03 Richard Biener <rguent...@suse.de> * tree-vect-loop.c (vect_transform_loop): Fix epilogue iterations for epilogue vectorization. Index: gcc/tree-vect-loop.c =================================================================== --- gcc/tree-vect-loop.c (revision 266739) +++ gcc/tree-vect-loop.c (working copy) @@ -8542,13 +8500,13 @@ vect_transform_loop (loop_vec_info loop_ targetm.vectorize.autovectorize_vector_sizes (&vector_sizes); unsigned int next_size = 0; + /* Note LOOP_VINFO_NITERS_KNOWN_P and LOOP_VINFO_INT_NITERS work + on niters already ajusted for the iterations of the prologue. */ if (LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo) - && LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo) >= 0 && known_eq (vf, lowest_vf)) { - unsigned int eiters + unsigned HOST_WIDE_INT eiters = (LOOP_VINFO_INT_NITERS (loop_vinfo) - - LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo) - LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo)); eiters = eiters % lowest_vf + LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo);