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

            Bug ID: 118906
           Summary: RISC-V: zcf is not implied by zce
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Yuriy.Kolerov at synopsys dot com
  Target Milestone: ---
            Target: riscv64-unknown-elf

Created attachment 60516
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60516&action=edit
A test file

According to the RISC-V Instruction Set Manual Volume I: "Specifying Zce on
RV32 with F includes Zca, Zcb, Zcmp, Zcmt and Zcf". However, Zcf is not implied
for -march=rv32if_zce.

You can reproduce this issue using a simple test file:

$ riscv64-unknown-elf-gcc -mriscv-attribute -march=rv32if_zce -mabi=ilp32 -S
test.c
$ grep "attribute arch" test.s
        .attribute arch,
"rv32i2p1_f2p2_zicsr2p0_zca1p0_zcb1p0_zce1p0_zcmp1p0_zcmt1p0"

The problem is in incorrect behavior of implication rules in riscv-common.cc
caused by a typo:

  {"zcf", "f",
   [] (const riscv_subset_list *subset_list) -> bool
   {
     return subset_list->xlen () == 32 && subset_list->lookup ("f");
   }},

This code is meaningless and does nothing. "zcf", "f" part must be replaced by
"zce", "zcf". I am preparing a patch for this issue.

GCC version:

$ riscv64-unknown-elf-gcc --version
riscv64-unknown-elf-gcc (g84f19ecb019) 15.0.1 20250213 (experimental)

System type:

$ uname -rvio
6.6.36.6-microsoft-standard-WSL2+ #1 SMP PREEMPT_DYNAMIC Thu Nov 28 17:58:07
+04 2024 x86_64 GNU/Linux

GCC configuration:

$ riscv64-unknown-elf-gcc -v
Using built-in specs.
COLLECT_GCC=./install-old/bin/riscv64-unknown-elf-gcc
COLLECT_LTO_WRAPPER=/SCRATCH/ykolerov/workspace/arc-v/testing/gcc-zce/install-old/libexec/gcc/riscv64-unknown-elf/15.0.1/lto-wrapper
Target: riscv64-unknown-elf
Configured with:
/SCRATCH/ykolerov/workspace/arc-v/testing/gcc-zce/gcc/configure
--target=riscv64-unknown-elf
--prefix=/SCRATCH/ykolerov/workspace/arc-v/testing/gcc-zce/install-old
--disable-shared --disable-threads --enable-languages=c,c++
--with-pkgversion=g84f19ecb019 --with-system-zlib --enable-tls --with-newlib
--with-headers=/SCRATCH/ykolerov/workspace/arc-v/testing/gcc-zce/install-old/riscv64-unknown-elf/include
--disable-libmudflap --disable-libssp --disable-libquadmath --disable-libgomp
--disable-nls --disable-tm-clone-registry
--src=/SCRATCH/ykolerov/workspace/arc-v/testing/gcc-zce/gcc --enable-multilib
--with-multilib-generator='rv32i-ilp32--;rv64i-lp64--' --with-abi=lp64d
--with-arch=rv64gc --with-tune=rocket --with-isa-spec=20191213 CFLAGS='-O0 -g'
CXXFLAGS='-O0 -g' 'CFLAGS_FOR_TARGET=-Os  -g  ' 'CXXFLAGS_FOR_TARGET=-Os  -g  '
Thread model: single
Supported LTO compression algorithms: zlib
gcc version 15.0.1 20250213 (experimental) (g84f19ecb019)

Reply via email to