https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69773
Bug ID: 69773 Summary: gcc ICE at -O2 and above on valid code on x86_64-linux-gnu in "assign_by_spills" Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: helloqirun at gmail dot com Target Milestone: --- The following valid code causes an ICE when compiled with the current gcc trunk at -O2 and above on x86_64-linux-gnu in both 32-bit and 64-bit modes. $ gcc-trunk -v Using built-in specs. COLLECT_GCC=gcc-trunk COLLECT_LTO_WRAPPER=/home/absozero/trunk/root-gcc/libexec/gcc/x86_64-pc-linux-gnu/6.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc/configure --prefix=/home/absozero/trunk/root-gcc --enable-languages=c,c++ --disable-werror --enable-multilib Thread model: posix gcc version 6.0.0 20160211 (experimental) [trunk revision 233345] (GCC) $ gcc-trunk -c -O2 abc.c abc.c: In function 'fn2': abc.c:18:1: error: unable to find a register to spill } ^ abc.c:18:1: error: this is the insn: (insn 11 30 29 3 (parallel [ (set (reg:SI 101 [95]) (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (reg:SI 102 [100])) (sign_extend:DI (reg:SI 96))) (const_int 32 [0x20])))) (clobber (reg:SI 102 [100])) (clobber (reg:CC 17 flags)) ]) abc.c:8 341 {*smulsi3_highpart_1} (expr_list:REG_UNUSED (reg:SI 102 [100]) (expr_list:REG_DEAD (reg:SI 96) (expr_list:REG_UNUSED (reg:CC 17 flags) (expr_list:REG_EQUAL (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (reg:SI 94 [ MEM[(struct str *)&f] ])) (const_int 1374389535 [0x51eb851f])) (const_int 32 [0x20]))) (nil)))))) abc.c:18:1: internal compiler error: in assign_by_spills, at lra-assigns.c:1417 0xaf7f38 _fatal_insn(char const*, rtx_def const*, char const*, int, char const*) ../../gcc/gcc/rtl-error.c:108 0x9f3575 assign_by_spills ../../gcc/gcc/lra-assigns.c:1417 0x9f3c23 lra_assign() ../../gcc/gcc/lra-assigns.c:1590 0x9ef6ab lra(_IO_FILE*) ../../gcc/gcc/lra.c:2322 0x9a6939 do_reload ../../gcc/gcc/ira.c:5395 0x9a6939 execute ../../gcc/gcc/ira.c:5566 Please submit a full bug report, with preprocessed source if appropriate. $ cat abc.c struct str { int k; } f; int g, a; int fn1(struct str *p1) { a = ({ register __typeof__(0) c asm("rdx"); g = p1->k / 100; c; }); return 0; } int fn2() { struct str h = f; if (g) fn1(&h); return 0; }