Skip to content

Hardware loops causes ICE in final_scan_insn_1

Reproducer

File test.c (test.c.tar.gz)

char *a;
int b, c;
int
d ()
{
  char e = 0;
  for (; e < 6; e++)
    a[b] |= a[e] |= a[b] |= a[c + e >> 4 * b] |= 80 >> e + 1;
}

Run with

riscv32-corev-elf-gcc -march=rv32imac_zicsr_xcvhwlp -mabi=ilp32 -Os -c -o test.o test.c

Output is

test.c: In function 'd':
test.c:9:1: error: could not split insn
    9 | }
      | ^
(insn 70 77 54 (parallel [
            (set (reg:SI 70 lpstart0)
                (unspec:SI [
                        (label_ref:SI 54)
                    ] UNSPEC_CV_FOLLOWS))
            (set (reg:SI 71 lpend0)
                (unspec:SI [
                        (label_ref:SI 0)
                    ] UNSPEC_CV_LP_END_12))
            (set (reg:SI 72 lpcount0)
                (const_int 6 [0x6]))
            (clobber (reg:SI 15 a5 [204]))
        ]) "test.c":7:12 discrim 1 244 {doloop_begin_i}
     (expr_list:REG_UNUSED (reg:SI 15 a5 [204])
        (insn_list:REG_LABEL_OPERAND 54 (insn_list:REG_LABEL_OPERAND 0 (nil)))))
during RTL pass: final
test.c:9:1: internal compiler error: in final_scan_insn_1, at final.cc:2808
0x18b2248 _fatal_insn(char const*, rtx_def const*, char const*, int, char const*)
	../../../gcc/gcc/rtl-error.cc:108
0x139f43e final_scan_insn_1
	../../../gcc/gcc/final.cc:2808
0x139f79d final_scan_insn(rtx_insn*, _IO_FILE*, int, int, int*)
	../../../gcc/gcc/final.cc:2887
0x139d4e5 final_1
	../../../gcc/gcc/final.cc:1979
0x13a266d rest_of_handle_final
	../../../gcc/gcc/final.cc:4240
0x13a29e4 execute
	../../../gcc/gcc/final.cc:4318
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

System information

Using built-in specs.
COLLECT_GCC=riscv32-corev-elf-gcc
COLLECT_LTO_WRAPPER=/home/jeremy/gittrees/dolphin/install/libexec/gcc/riscv32-corev-elf/14.0.0/lto-wrapper
Target: riscv32-corev-elf
Configured with: ../../gcc/configure --target=riscv32-corev-elf --prefix=/home/jeremy/gittrees/dolphin/install --with-sysroot=/home/jeremy/gittrees/dolphin/install/riscv32-corev-elf --with-native-system-header-dir=/include --with-newlib --disable-shared --enable-languages=c,c++ --enable-tls --disable-werror --disable-libmudflap --disable-libssp --disable-quadmath --disable-libgomp --disable-nls --enable-multilib --with-multilib-generator='rv32i-ilp32--c                                    rv32ia-ilp32--m                      	     rv32im-ilp32--c                      	     rv32if-ilp32f-rv32ifd-c              	     rv32iaf-ilp32f-rv32imaf,rv32iafc-d   	     rv32imf-ilp32f-rv32imfd-c            	     rv32iac-ilp32--                      	     rv32imac-ilp32--                     	     rv32imafc-ilp32f-rv32imafdc-         	     rv32ifd-ilp32d--c                    	     rv32imfd-ilp32d--c                   	     rv32iafd-ilp32d-rv32imafd,rv32iafdc- 	     rv32imafdc-ilp32d--' --with-arch=rv32imac --with-abi=ilp32 : (reconfigured) ../../gcc/configure --target=riscv32-corev-elf --prefix=/home/jeremy/gittrees/dolphin/install --with-sysroot=/home/jeremy/gittrees/dolphin/install/riscv32-corev-elf --with-native-system-header-dir=/include --with-newlib --disable-shared --enable-languages=c,c++ --enable-tls --disable-werror --disable-libmudflap --disable-libssp --disable-quadmath --disable-libgomp --disable-nls --enable-multilib --with-multilib-generator='rv32i-ilp32--c                                    rv32ia-ilp32--m                      	     rv32im-ilp32--c                      	     rv32if-ilp32f-rv32ifd-c              	     rv32iaf-ilp32f-rv32imaf,rv32iafc-d   	     rv32imf-ilp32f-rv32imfd-c            	     rv32iac-ilp32--                      	     rv32imac-ilp32--                     	     rv32imafc-ilp32f-rv32imafdc-         	     rv32ifd-ilp32d--c                    	     rv32imfd-ilp32d--c                   	     rv32iafd-ilp32d-rv32imafd,rv32iafdc- 	     rv32imafdc-ilp32d--' --with-arch=rv32imac --with-abi=ilp32
Thread model: single
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230928 (experimental) (GCC)