The following simplified example causes an ICE in GCC for the versions listed in title, but not 12.2.0 (20230208).
Tested with local copies of the tool chain on windows
Tested with a local VM instance of Compiler Explorer (godbolt) with the 13.2 release just to confirm it wasn't anything in my local OS/install.
Does not occur in O2/O3/Os if -fno-expensive-optimizations and/or -fno-tree-sra are set
Seems to always occur in O1 and Og regardless of above flags
Whether it's triggered mostly seems to be whether the size of the bytes allow them to be scalarized and(?) whether the narrow/immediate instructions can be used.
Seems like there are shenanigans when GCC tries to optimize the value structure then build the SLL/SLLI and MOVI/MOVI.N instruction assignments. I am not a compiler dev so out of my league here.
Reproduction is fairly simple, compile with -Os to crash, compile with -Os -fno-tree-sra and/or -Os -fno-expensive-optimizations to workaround.
Simplified Reproduction
#include <cstdint>
struct command
{
uint8_t address;
uint8_t data;
};
//triggers ICE in elimination_costs_in_insn, at reload1.cc:3539 unless compiled with -fno-expensive-optimizations
command triggersICE()
{
return command{0x01, 0b1000};
};
//Nothing below this line is necessary to reproduce, just for clarity on what does/does not trigger the bug.
command triggersICEB()
{
return command{0xff, 0xf7};
};
command doesNotTriggerICEA()
{
return command{0x00, 0b1000};
};
command doesNotTriggerICEB()
{
return command{0xff, 0b100};
};
command doesNotTriggerICEC()
{
return command{0x01, 0b111};
};
command doesNotTriggerICED()
{
return command{0xff, 0xf8};
};
GCC Error
during RTL pass: ira
<source>: In function 'command triggersICE()':
<source>:12:1: internal compiler error: in elimination_costs_in_insn, at reload1.cc:3539
12 | };
| ^
0x164b716 internal_error(char const*, ...)
???:0
0x66c633 fancy_abort(char const*, int, char const*)
???:0
0xd21894 calculate_elim_costs_all_insns()
???:0
0xbcde8c ira_costs()
???:0
0xbc75b4 ira_build()
???:0
The following simplified example causes an ICE in GCC for the versions listed in title, but not 12.2.0 (20230208).
O2
/O3
/Os
if-fno-expensive-optimizations
and/or-fno-tree-sra
are setO1
andOg
regardless of above flagsSeems like there are shenanigans when GCC tries to optimize the value structure then build the SLL/SLLI and MOVI/MOVI.N instruction assignments. I am not a compiler dev so out of my league here.
Reproduction is fairly simple, compile with
-Os
to crash, compile with-Os -fno-tree-sra
and/or-Os -fno-expensive-optimizations
to workaround.Simplified Reproduction
GCC Error
Failing IRA Pass Emergency Dump