diff options
Diffstat (limited to 'gcc/tree-vect-data-refs.c')
-rw-r--r-- | gcc/tree-vect-data-refs.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c index 893ad5a..8785d10 100644 --- a/gcc/tree-vect-data-refs.c +++ b/gcc/tree-vect-data-refs.c @@ -1515,10 +1515,20 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo) || !slpeel_can_duplicate_loop_p (loop, single_exit (loop))) do_peeling = false; - if (do_peeling && all_misalignments_unknown + /* If we don't know how many times the peeling loop will run + assume it will run VF-1 times and disable peeling if the remaining + iters are less than the vectorization factor. */ + if (do_peeling + && all_misalignments_unknown + && LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo) + && (LOOP_VINFO_INT_NITERS (loop_vinfo) + < 2 * (unsigned) LOOP_VINFO_VECT_FACTOR (loop_vinfo) - 1)) + do_peeling = false; + + if (do_peeling + && all_misalignments_unknown && vect_supportable_dr_alignment (dr0, false)) { - /* Check if the target requires to prefer stores over loads, i.e., if misaligned stores are more expensive than misaligned loads (taking drs with same alignment into account). */ @@ -1605,6 +1615,14 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo) &body_cost_vec); if (!dr0 || !npeel) do_peeling = false; + + /* If peeling by npeel will result in a remaining loop not iterating + enough to be vectorized then do not peel. */ + if (do_peeling + && LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo) + && (LOOP_VINFO_INT_NITERS (loop_vinfo) + < LOOP_VINFO_VECT_FACTOR (loop_vinfo) + npeel)) + do_peeling = false; } if (do_peeling) |