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

--- Comment #15 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by hongtao Liu <liuho...@gcc.gnu.org>:

https://gcc.gnu.org/g:209f02b0a9e9adc0bf0247cb5eef04e0f175d64e

commit r13-5644-g209f02b0a9e9adc0bf0247cb5eef04e0f175d64e
Author: liuhongt <hongtao....@intel.com>
Date:   Wed Feb 1 13:30:12 2023 +0800

    Don't peel nonlinear iv(mult or shift) for epilog when vf is not constant.

    Normally when vf is not constant, it will be prevented by
    vectorizable_nonlinear_inductions, but for this case, it failed going
    into

        if (STMT_VINFO_RELEVANT_P (stmt_info))
          {
            need_to_vectorize = true;
            if (STMT_VINFO_DEF_TYPE (stmt_info) == vect_induction_def
               && ! PURE_SLP_STMT (stmt_info))
              ok = vectorizable_induction (loop_vinfo,
                                           stmt_info, NULL, NULL,
                                           &cost_vec);

    since the iv is never used outside of the loop, and will be dce later, so
    vectorizer doesn't bother checking if it's vectorizable. it's
    true but hit gcc_assert in vect_can_peel_nonlinear_iv_p when vf is not
    constant. One solution is ignoring the nonlinear iv peeling if it's
    !STMT_VINFO_RELEVANT_P (stmt_info) just like the upper code, the other
    solution is returning false earlier in the
    vect_can_peel_nonlinear_iv_p when vf is not constant, the patch chooses
    the second incase there's other cases using vect_can_advance_ivs_p which
    calls vect_can_peel_nonlinear_iv_p.
    Also remove vect_peel_nonlinear_iv_p from
    vectorizable_nonlinear_inductions.

    gcc/ChangeLog:

            PR tree-optimization/108601
            * tree-vectorizer.h (vect_can_peel_nonlinear_iv_p): Removed.
            * tree-vect-loop.cc
            (vectorizable_nonlinear_induction): Remove
            vect_can_peel_nonlinear_iv_p.
            (vect_can_peel_nonlinear_iv_p): Don't peel
            nonlinear iv(mult or shift) for epilog when vf is not
            constant and moved the defination to ..
            * tree-vect-loop-manip.cc (vect_can_peel_nonlinear_iv_p):
            .. Here.

    gcc/testsuite/ChangeLog:

            * gcc.target/aarch64/pr108601.c: New test.

Reply via email to