https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122025
Bug ID: 122025
Summary: wrong code with -Og -fdep-fusion -fno-dce
-funroll-loops --param=max-cse-insns=0
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: rtl-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: zsojka at seznam dot cz
Target Milestone: ---
Host: x86_64-pc-linux-gnu
Target: armv7a-hardfloat-linux-gnueabi
Created attachment 62433
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62433&action=edit
reduced testcase
Output:
$ armv7a-hardfloat-linux-gnueabi-gcc -Og -fdep-fusion -fno-dce -funroll-loops
--param=max-cse-insns=0 testcase.c -static
$ qemu-arm -- ./a.out
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
Segmentation fault
In the ASM output:
...
rsb ip, r3, r1, asr #29
rsb r1, ip, ip, lsl #31
sub r2, r2, r1
str r2, [r1]
...
r1 is used for computation, and then for addressing
$ armv7a-hardfloat-linux-gnueabi-gcc -v
Using built-in specs.
COLLECT_GCC=/repo/gcc-trunk/binary-latest-armv7a-hardfloat/bin/armv7a-hardfloat-linux-gnueabi-gcc
COLLECT_LTO_WRAPPER=/repo/gcc-trunk/binary-trunk-20250922083307-r16-4016-g5e6937b9ab4f75-checking-yes-rtl-df-extra-armv7a-hardfloat/bin/../libexec/gcc/armv7a-hardfloat-linux-gnueabi/16.0.0/lto-wrapper
Target: armv7a-hardfloat-linux-gnueabi
Configured with: /repo/gcc-trunk//configure --enable-languages=c,c++
--enable-valgrind-annotations --disable-nls --enable-checking=yes,rtl,df,extra
--enable-libsanitizer --with-float=hard --with-fpu=vfpv4 --with-arch=armv7-a
--with-sysroot=/usr/armv7a-hardfloat-linux-gnueabi --build=x86_64-pc-linux-gnu
--host=x86_64-pc-linux-gnu --target=armv7a-hardfloat-linux-gnueabi
--with-ld=/usr/bin/armv7a-hardfloat-linux-gnueabi-ld
--with-as=/usr/bin/armv7a-hardfloat-linux-gnueabi-as --disable-libstdcxx-pch
--prefix=/repo/gcc-trunk//binary-trunk-20250922083307-r16-4016-g5e6937b9ab4f75-checking-yes-rtl-df-extra-armv7a-hardfloat
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 16.0.0 20250922 (experimental) (GCC)