https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111820
--- Comment #9 from Hongtao.liu <crazylht at gmail dot com> ---
> But we end up here with niters_skip being INTEGER_CST and ..
>
> > 1421 || (!vect_use_loop_mask_for_alignment_p (loop_vinfo)
>
> possibly vect_use_loop_mask_for_alignment_p. Note
> LOOP_VINFO_PEELING_FOR_ALIGNMENT < 0 simply means the amount of
> peeling is unknown.
>
> But I wonder how we run into this on x86 without enabling
> loop masking ...
>
> > 1422 && LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo) < 0))
> > 1423 {
> > 1424 if (dump_enabled_p ())
> > 1425 dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
> > 1426 "Peeling for alignement is not supported"
> > 1427 " for nonlinear induction when niters_skip"
> > 1428 " is not constant.\n");
> > 1429 return false;
> > 1430 }
Can you point out where it's assigned as nagative?
I saw LOOP_VINFO_MASK_SKIP_NITERS is only assigned in
vect_prepare_for_masked_peels.
when LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo) > 0
it's assigned as vf-npeel(will npeel > vf?)
else
it's assigned in get_misalign_in_elems and should be positive.
HOST_WIDE_INT elem_size
= int_cst_value (TYPE_SIZE_UNIT (TREE_TYPE (vectype)));
tree elem_size_log = build_int_cst (type, exact_log2 (elem_size));
/* Create: misalign_in_bytes = addr & (target_align - 1). */
tree int_start_addr = fold_convert (type, start_addr);
tree misalign_in_bytes = fold_build2 (BIT_AND_EXPR, type, int_start_addr,
target_align_minus_1);
/* Create: misalign_in_elems = misalign_in_bytes / element_size. */
tree misalign_in_elems = fold_build2 (RSHIFT_EXPR, type, misalign_in_bytes,
elem_size_log);
return misalign_in_elems;
void
vect_prepare_for_masked_peels (loop_vec_info loop_vinfo)
{
tree misalign_in_elems;
tree type = TREE_TYPE (LOOP_VINFO_NITERS (loop_vinfo));
gcc_assert (vect_use_loop_mask_for_alignment_p (loop_vinfo));
/* From the information recorded in LOOP_VINFO get the number of iterations
that need to be skipped via masking. */
if (LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo) > 0)
{
poly_int64 misalign = (LOOP_VINFO_VECT_FACTOR (loop_vinfo)
- LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo));
misalign_in_elems = build_int_cst (type, misalign);
}
else
{
gimple_seq seq1 = NULL, seq2 = NULL;
misalign_in_elems = get_misalign_in_elems (&seq1, loop_vinfo);
misalign_in_elems = fold_convert (type, misalign_in_elems);
misalign_in_elems = force_gimple_operand (misalign_in_elems,
&seq2, true, NULL_TREE);
gimple_seq_add_seq (&seq1, seq2);
if (seq1)
{
edge pe = loop_preheader_edge (LOOP_VINFO_LOOP (loop_vinfo));
basic_block new_bb = gsi_insert_seq_on_edge_immediate (pe, seq1);
gcc_assert (!new_bb);
}
}
if (dump_enabled_p ())
dump_printf_loc (MSG_NOTE, vect_location,
"misalignment for fully-masked loop: %T\n",
misalign_in_elems);
LOOP_VINFO_MASK_SKIP_NITERS (loop_vinfo) = misalign_in_elems;
vect_update_inits_of_drs (loop_vinfo, misalign_in_elems, MINUS_EXPR);
}