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

--- Comment #11 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Robin Dapp <[email protected]>:

https://gcc.gnu.org/g:a98b6cf01ba9fb69450a5e883c5d8e8600e2cc95

commit r16-5118-ga98b6cf01ba9fb69450a5e883c5d8e8600e2cc95
Author: Robin Dapp <[email protected]>
Date:   Fri Nov 7 15:54:52 2025 +0100

    vect: Do not set range for step != 1 [PR121985].

    In PR120922 we first disabled setting a range on niters_vector for
    partial vectorization and later introduced a ceiling division instead.

    In PR121985 we ran into this again where a bogus range caused wrong code
    later.  On top I saw several instances of this issue on a local branch
    that enables more VLS length-controlled loops.

    I believe we must not set niter_vector's range to TYPE_MAX / VF, no
    matter the rounding due to the way niters_vector is used.  It's not
    really identical to the number of vector iterations but the actual
    number the loop will iterate is niters_vector / step where step = VF
    for partial vectors.

    Thus, only set the range to TYPE_MAX / VF if step == 1.

    gcc/ChangeLog:

            PR middle-end/121985

            * tree-vect-loop-manip.cc (vect_gen_vector_loop_niters): Only
            set niter_vector's range if step == 1.

    gcc/testsuite/ChangeLog:

            * gcc.target/riscv/rvv/autovec/pr121985.c: New test.

Reply via email to