https://gcc.gnu.org/bugzilla/show_bug.cgi?id=129062
Bug ID: 129062
Summary: RISC-V GCC accepts an RV32 -march option that enables
both Zclsd and Zcf
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: majin at gcc dot gnu.org
Target Milestone: ---
Description:
GCC accepts -march=rv32gc_zilsd_zclsd. This combination implicitly enables
Zcf, whose instruction encodings overlap with those of Zclsd.
Compiler information
GCC 17.0.0 20261123 (experimental), targeting riscv64-unknown-linux-gnu.
The tested local commit was d1e8fc5427257698068c62ea8eefc40c4041aa8d.
The upstream master base was 50fa5ffebbd6dc02dd045fff75923a5409d9f169.
Both revisions have identical code for RISC-V extension dependencies and
conflict checks.
Reproducer
Save the following as testcase.c.
int foo()
{
}
riscv64-unknown-linux-gnu-gcc -O0 -march=rv32gc_zilsd_zclsd -mabi=ilp32d -S
testcase.c -o testcase.s
Actual result
GCC generates testcase.s without diagnosing the extension conflict.
Expected result
GCC should reject this -march option and report the conflict between Zclsd
and Zcf. G includes F, and enabling both C and F on RV32 implies Zcf.
The compressed load/store instructions in Zclsd and Zcf have overlapping
encodings.
Specification
Section 34.1.2 of the RISC-V Unprivileged ISA Specification (20260120)
states that Zclsd and Zcf are incompatible. Section 28.1.2 specifies when
C implies Zcf on RV32.
https://docs.riscv.org/reference/isa/v20260120/unpriv/zilsd.html#zclsd
https://docs.riscv.org/reference/isa/v20260120/unpriv/zc.html#C