[Bug target/123824] riscv: Incorrect passing of VLS vectors via the stack.

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jan 28 19:10:31 GMT 2026


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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Robin Dapp <rdapp@gcc.gnu.org>:

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

commit r16-7122-gcb0d29db88e367a709f32e49bfa540e54db02f82
Author: Robin Dapp <rdapp@oss.qualcomm.com>
Date:   Mon Jan 26 17:59:58 2026 +0100

    RISC-V: Fix ABI vector passing on stack and GPR [PR123824].

    Krister reported that we violate the psABI when one vector argument
    halfway fits into a register:

    "Aggregates whose total size is no more than 2×XLEN bits are passed in a
    pair of registers; if only one register is available, the first XLEN
    bits are passed in a register and the remaining bits are passed on the
    stack. If no registers are available, the aggregate is passed on the
    stack."

    This patch fixes this oversight and adds a few tests.

    Regtested on rv64gcv_zvl512b.

            PR target/123824

    gcc/ChangeLog:

            * config/riscv/riscv.cc (riscv_vls_mode_fits_in_gprs_p): New
            helper.
            (riscv_pass_vls_aggregate_in_gpr): Use helper and distribute
            half-fitting vector to GPR and stack.
            (riscv_pass_aggregate_in_vr): Reformat comment.
            (riscv_get_arg_info): Use helper.
            (riscv_pass_by_reference): Ditto.

    gcc/testsuite/ChangeLog:

            * gcc.target/riscv/abi/vls-gpr-1.c: New test.
            * gcc.target/riscv/abi/vls-gpr-10.c: New test.
            * gcc.target/riscv/abi/vls-gpr-11.c: New test.
            * gcc.target/riscv/abi/vls-gpr-12.c: New test.
            * gcc.target/riscv/abi/vls-gpr-13.c: New test.
            * gcc.target/riscv/abi/vls-gpr-14.c: New test.
            * gcc.target/riscv/abi/vls-gpr-2.c: New test.
            * gcc.target/riscv/abi/vls-gpr-3.c: New test.
            * gcc.target/riscv/abi/vls-gpr-4.c: New test.
            * gcc.target/riscv/abi/vls-gpr-5.c: New test.
            * gcc.target/riscv/abi/vls-gpr-6.c: New test.
            * gcc.target/riscv/abi/vls-gpr-7.c: New test.
            * gcc.target/riscv/abi/vls-gpr-8.c: New test.
            * gcc.target/riscv/abi/vls-gpr-9.c: New test.


More information about the Gcc-bugs mailing list