https://gcc.gnu.org/bugzilla/show_bug.cgi?id=129072
Bug ID: 129072
Summary: [17 Regression] RISC-V: ICE in
riscv_print_operand_address when an atomic add uses a
floating-point base register
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:
Building libgomp at -O2 triggers this ICE in both gomp_team_start and
omp_aligned_calloc. The following C test case reproduces it on its own.
Compiler information
GCC 17.0.0 20261120 (experimental)
Target: riscv64-unknown-linux-gnu
GCC master revision tested: 1c6bee45b4c3d9f2500430371ef61d9487a5b8e7
Reproducer
Save the following as testcase.c.
void
atomic_add (double bits)
{
union { double bits; int *addr; } u = { bits };
__atomic_fetch_add (u.addr, 1, __ATOMIC_RELAXED);
}
riscv64-unknown-linux-gnu-gcc -O2 -march=rv64gc -mabi=lp64d -mtune=xt-c9501fdvt
-c testcase.c
Actual result
during RTL pass: final
testcase.c: In function 'atomic_add':
testcase.c:6:1: internal compiler error: in riscv_print_operand_address, at
config/riscv/riscv.cc:9268
Expected result
The test case should compile, and the generated amoadd.w should use a
general-purpose base register.
Regression information
The parent commit 23022fdcd5ca8439049cca24b8c7d91f8fec9362 compiles the same
test case. The first failing commit, 1c6bee45b4c3, allows integer-mode
pseudos to be allocated to floating-point registers. This exposes a bug
in the A memory constraint, which accepts a floating-point base register.
Adding -fdisable-rtl-late_combine2 to the command line makes the test case
compile on the failing revision.