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

--- Comment #1 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jeff Law <l...@gcc.gnu.org>:

https://gcc.gnu.org/g:42ce61eaefc4db70e2e7ea2d8ef091daa458eb48

commit r16-124-g42ce61eaefc4db70e2e7ea2d8ef091daa458eb48
Author: Yuriy Kolerov <yuriy.kole...@synopsys.com>
Date:   Thu Apr 24 21:22:16 2025 -0600

    [PATCH] RISC-V: Imply C from Zca whenever possible [PR119122]

    GCC must imply C extension from Zca extension when it's
    possible. It's necessary for achieving compatibility
    between different march strings which in fact may be
    the same.

    E.g., if rv32ic multilib configuration is presented in
    GCC, then GCC will not choose this configuration for
    linking if -march=rv32i_zca is passed.

    Here is a more practical example. From RISC-V
    Instruction Set Manual:

        Therefore common ISA strings can be updated as follows
        to include the relevant Zc extensions, for example:
            - RV32IMC becomes RV32IM_Zce
            - RV32IMCF becomes RV32IMF_Zce

    With current implication rules this will not work well
    if rv32imc configuration is presented and a user
    passes -march=rv32im_zce. This is how we can check
    this with a simple empty test.c source file:

    $ riscv64-unknown-elf-gcc -march=rv32ic -mabi=ilp32 -mriscv-attribute -S
test.c
    $ grep "attribute arch" test.s
            .attribute arch, "rv32i2p1_c2p0_zca1p0"
    $ riscv64-unknown-elf-gcc -march=rv32i_zce -mabi=ilp32 -mriscv-attribute -S
test.c
    $ grep "attribute arch" test.s
            .attribute arch,
"rv32i2p1_zicsr2p0_zca1p0_zcb1p0_zce1p0_zcmp1p0_zcmt1p0"

    According to current GCC these march strings are
    incompatible: the first one contains c2p0 and the
    second on doesn't.

    To introduce such implication rule we need to carefully
    cover all possible combinations with these extensions:
    zca, zcf, zcd, F and D.

    According to the same manual:

        As C defines the same instructions as Zca, Zcf and
        Zcd, the rule is that:
            - C always implies Zca
            - C+F implies Zcf (RV32 only)
            - C+D implies Zcd

    Here is a full list of cases:

        1. rv32i_zca implies C.
        2. rv32if_zca_zcf implies C.
        3. rv32ifd_zca_zcf_zcd implies C.
        4. rv64i_zca implies C.
        5. rv64ifd_zca_zcd implies C.

            PR target/119122

    gcc/ChangeLog:

            * common/config/riscv/riscv-common.cc (riscv_implied_info): Add a
rule
            for Zca to C implication.

    gcc/testsuite/ChangeLog:

            * gcc.target/riscv/arch-25.c: Fix dg-error expectation.
            * gcc.target/riscv/attribute-c-1.c: New test.
            * gcc.target/riscv/attribute-c-2.c: New test.
            * gcc.target/riscv/attribute-c-3.c: New test.
            * gcc.target/riscv/attribute-c-4.c: New test.
            * gcc.target/riscv/attribute-c-5.c: New test.
            * gcc.target/riscv/attribute-c-6.c: New test.
            * gcc.target/riscv/attribute-c-7.c: New test.
            * gcc.target/riscv/attribute-c-8.c: New test.
            * gcc.target/riscv/attribute-zce-1.c: Update Zce tests.
            * gcc.target/riscv/attribute-zce-2.c: Likewise.
            * gcc.target/riscv/attribute-zce-3.c: Likewise
            * gcc.target/riscv/attribute-zce-4.c: Likewise.
  • [Bug target/119122] Zca does no... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to