https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80540
Bug ID: 80540 Summary: gcc ICE at -O2 and above on x86_64-linux-gnu in "assign_by_spills" Product: gcc Version: 8.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 code causes an ICE when compiled with the current gcc trunk at -O2 and above on x86_64-linux-gnu in both 32- and 64-bit modes. Unlike PR79636, -O0 and -O1 work fine. Moreover, gcc-4.8.5 crashes at all levels; gcc-4.9 accepts it at all levels; gcc-5.X,6 accept it at -O1 and -O0, and reject it at -O2 and above. $ gcc-trunk --version gcc-trunk (GCC) 8.0.0 20170426 (experimental) [trunk revision 247284] Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ gcc-trunk -O2 abc.c abc.c: In function ‘fn2’: abc.c:15:1: error: unable to find a register to spill } ^ abc.c:15:1: error: this is the insn: (insn 14 37 36 3 (parallel [ (set (reg:SI 101 [94]) (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (reg:SI 102 [100])) (sign_extend:DI (reg:SI 95))) (const_int 32 [0x20])))) (clobber (reg:SI 102 [100])) (clobber (reg:CC 17 flags)) ]) "abc.c":5 355 {*smulsi3_highpart_1} (expr_list:REG_UNUSED (reg:SI 102 [100]) (expr_list:REG_DEAD (reg:SI 95) (expr_list:REG_UNUSED (reg:CC 17 flags) (expr_list:REG_EQUAL (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (reg:SI 93 [ a ])) (const_int 274877907 [0x10624dd3])) (const_int 32 [0x20]))) (nil)))))) abc.c:15:1: internal compiler error: in assign_by_spills, at lra-assigns.c:1476 0xb19c98 _fatal_insn(char const*, rtx_def const*, char const*, int, char const*) ../../gcc/gcc/rtl-error.c:108 0xa07acb assign_by_spills ../../gcc/gcc/lra-assigns.c:1476 0xa08526 lra_assign() ../../gcc/gcc/lra-assigns.c:1670 0xa03ad4 lra(_IO_FILE*) ../../gcc/gcc/lra.c:2451 0x9b9dd1 do_reload ../../gcc/gcc/ira.c:5472 0x9b9dd1 execute ../../gcc/gcc/ira.c:5656 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. $ cat abc.c int g, a; void fn1() { int b = ({ register __typeof__(0) c asm("rdx"); g = a / 1000; c; }); if (b) a = 0; } void fn2() { switch (g) case 0: fn1(); }