https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106905

--- Comment #3 from Hongtao.liu <crazylht at gmail dot com> ---
in vectorizable_nonlinear_induction, we prevent variable peeling by only
checking LOOP_VINFO_MASK_SKIP_NITERS (loop_vinfo).
But when "!vect_use_loop_mask_for_alignment_p (loop_vinfo) &&
LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo) < 0", vectorizer will also do
variable peeling for epilog, and it hits gcc_assert in
vect_peel_nonlinear_iv_init.


I'm testing

diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 8f88f1755be..9c434b66c5b 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -8646,8 +8646,10 @@ vectorizable_nonlinear_induction (loop_vec_info
loop_vinfo,
   /* Also doens't support peel for neg when niter is variable.
      ??? generate something like niter_expr & 1 ? init_expr : -init_expr?  */
   niters_skip = LOOP_VINFO_MASK_SKIP_NITERS (loop_vinfo);
-  if (niters_skip != NULL_TREE
-      && TREE_CODE (niters_skip) != INTEGER_CST)
+  if ((niters_skip != NULL_TREE
+       && TREE_CODE (niters_skip) != INTEGER_CST)
+      || (!vect_use_loop_mask_for_alignment_p (loop_vinfo)
+         && LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo) < 0))
     {
       if (dump_enabled_p ())
        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,

Reply via email to