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

            Bug ID: 118284
           Summary: [RISCV] No compressed c.j for offsets of -2044, -2046,
                    -2048
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tommy_murphy at hotmail dot com
  Target Milestone: ---

Created attachment 60038
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60038&action=edit
Simple test case code

Originally reported here:

https://github.com/riscv-collab/riscv-gnu-toolchain/issues/1647

See the attached simple test code cj.S.

For offsets of up to -2040 and also -2042 a 16-bit compressed c.j <offset> is
generated but for offsets of -2044, -2046 and -2048 a 32-bit (non-compressed)
jal x0, <offset> instruction is generated.

Is this an offset edge case error in the code generation or is there some other
explanation for this behaviour?

If any further information or clarification is needed please let me know.
Thanks! :-)


Tested with GCC 15.0.0 built using the riscv-gnu-toolchain repo:

git clone https://github.com/riscv-collab/riscv-gnu-toolchain issue-1647
cd issue-1647
git clone https://github.com/gcc-mirror/gcc gcc-upstream-master --depth=1
./configure --prefix=`pwd`/installed-tools --disable-gdb
--with-gcc-src=`pwd`/gcc-upstream-master
make

./installed-tools/bin/riscv64-unknown-elf-gcc -v
Using built-in specs.
COLLECT_GCC=./riscv64-unknown-elf-gcc
COLLECT_LTO_WRAPPER=/home/user/issue-1647/installed-tools/libexec/gcc/riscv64-unknown-elf/15.0.0/lto-wrapper
Target: riscv64-unknown-elf
Configured with: /home/user/issue-1647/gcc-upstream-master/configure
--target=riscv64-unknown-elf --prefix=/home/user/issue-1647/installed-tools
--disable-shared --disable-threads --enable-languages=c,c++
--with-pkgversion=gf8b559626 --with-system-zlib --enable-tls --with-newlib
--with-sysroot=/home/user/issue-1647/installed-tools/riscv64-unknown-elf
--with-native-system-header-dir=/include --disable-libmudflap --disable-libssp
--disable-libquadmath --disable-libgomp --disable-nls
--disable-tm-clone-registry --src=/home/user/issue-1647/gcc-upstream-master
--disable-multilib --with-abi=lp64d --with-arch=rv64gc --with-tune=rocket
--with-isa-spec=20191213 'CFLAGS_FOR_TARGET=-Os    -mcmodel=medlow'
'CXXFLAGS_FOR_TARGET=-Os    -mcmodel=medlow'
Thread model: single
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20250101 (experimental) (gf8b559626)

Reply via email to