https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127352

            Bug ID: 127352
           Summary: [16/17 Regression] ICE in gen_reg_rtx at -O3
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: shimizu2486 at gmail dot com
  Target Milestone: ---

Live Reproducer: https://godbolt.org/z/EbWrxManP
Compiling the following C with -O3 on x86_64-pc-linux-gnu 17.0.0 (trunk)
produces ICE:

$ cat ice.c
static long long add64(long long a, int b) { return a; }
static unsigned _BitInt(13) mod13(unsigned _BitInt(13) a, unsigned _BitInt(13)
b) { return b == 0 ? 1 : a; }
static _BitInt(65) mod65(_BitInt(65) a, _BitInt(65) b) { return b == 0 ? a : b;
}
_BitInt(65) g0, g1, g2;
__int128 w;
_BitInt(7) b7;
_BitInt(47) f0(long long p0) {
  return ~add64(~(_BitInt(65))p0, 0);
}
_BitInt(5) f1(void) {
  unsigned n1 = w & 15;
  for (unsigned i2 = 0; i2 < n1; i2++) {
    switch ((_BitInt(13))g0) {
    case 0: g1 = 0;
    case 8: b7 = 0; break;
    case 10: b7 = f0(n1);
    }
    if (0 >= g1) continue;
    for (unsigned i4 = 0; i4 < 1; i4++)
      g1 = (_BitInt(7))(0 >= w ? mod13(b7, g0) : 0);
    b7 = g2 ? mod65(g1, i2) : 0;
  }
  return g1;
}

This is an ICE on valid code. Compies on -O0 and no UB within.

$ gcc -O3 -c ice.c
during RTL pass: split2
ice.c:24:1: internal compiler error: in gen_reg_rtx, at emit-rtl.cc:1192
0x8381e3 gen_reg_rtx(machine_mode)
        ../../gcc/emit-rtl.cc:1192
0x1c94117 split_double_mode(machine_mode, rtx_def**, int, rtx_def**, rtx_def**)
        ../../gcc/config/i386/i386-expand.cc:166
0x26bc6ab gen_split_290(rtx_insn*, rtx_def**)
        ../../gcc/config/i386/i386.md:13311
0x2aa97e7 split_insns(rtx_def*, rtx_insn*)
        ../../gcc/config/i386/i386.md:21891
0x11dbe9e try_split(rtx_def*, rtx_insn*, int)
        ../../gcc/emit-rtl.cc:3960
0x1637077 split_insn
        ../../gcc/recog.cc:3529
0x163e955 split_all_insns()
        ../../gcc/recog.cc:3636


  14         compiles
  15         compiles
  16         ICE
  17 (trunk) ICE

Reply via email to