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

--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-14 branch has been updated by Kito Cheng <k...@gcc.gnu.org>:

https://gcc.gnu.org/g:95ac2d8afb386ccd7277f4906e0aca88d53c835a

commit r14-11570-g95ac2d8afb386ccd7277f4906e0aca88d53c835a
Author: Robin Dapp <rd...@ventanamicro.com>
Date:   Wed Jul 31 16:54:03 2024 +0200

    RISC-V: Correct mode_idx attribute for viwalu wx variants [PR116149].

    In PR116149 we choose a wrong vector length which causes wrong values in
    a reduction.  The problem happens in avlprop where we choose the
    number of units in the instruction's mode as vector length.  For the
    non-scalar variants the respective operand has the correct non-widened
    mode.  For the scalar variants, however, the same operand has a scalar
    mode which obviously only has one unit.  This makes us choose VL = 1
    leaving three elements undisturbed (so potentially -1).  Those end up
    in the reduction causing the wrong result.

    This patch adjusts the mode_idx just for the scalar variants of the
    affected instruction patterns.

    gcc/ChangeLog:

            PR target/116149

            * config/riscv/vector.md: Fix mode_idx attribute of scalar
            widen add/sub variants.

    gcc/testsuite/ChangeLog:

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

Reply via email to