http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59166

            Bug ID: 59166
           Summary: ICE in simplify_subreg, at simplify-rtx.c:5901 on
                    valid code (at -O1 and above with -g enabled)
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: su at cs dot ucdavis.edu

The following code causes an ICE when compiled with the current gcc trunk at
-O1 and above with -g enabled (except -Os in 64-bit mode) on x86_64-linux-gnu.

This is a regression from 4.8.x.

$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure
--enable-languages=c,c++,objc,obj-c++,fortran,lto --disable-werror
--with-gmp=/usr/local/gcc-trunk --with-mpfr=/usr/local/gcc-trunk
--with-mpc=/usr/local/gcc-trunk --with-cloog=/usr/local/gcc-trunk
--prefix=/usr/local/gcc-trunk
Thread model: posix
gcc version 4.9.0 20131117 (experimental) [trunk revision 204923] (GCC) 
$ 
$ gcc-trunk -O0 -g small.c; a.out
$ gcc-trunk -O1 small.c; a.out
$ gcc-4.8.2 -O1 -g small.c; a.out
$ 
$ gcc-trunk -O1 -g small.c    
small.c: In function ‘fn1’:
small.c:26:1: internal compiler error: in simplify_subreg, at
simplify-rtx.c:5901
 }
 ^
0x98caf6 simplify_subreg(machine_mode, rtx_def*, machine_mode, unsigned int)
    ../../gcc-trunk/gcc/simplify-rtx.c:5900
0x98cc1d simplify_gen_subreg
    ../../gcc-trunk/gcc/simplify-rtx.c:6121
0xbf2fba vt_expand_loc_callback
    ../../gcc-trunk/gcc/var-tracking.c:8328
0x6a5575 cselib_expand_value_rtx_1
    ../../gcc-trunk/gcc/cselib.c:1649
0x6a698e cselib_expand_value_rtx_cb(rtx_def*, bitmap_head_def*, int, rtx_def*
(*)(rtx_def*, bitmap_head_def*, int, void*), void*)
    ../../gcc-trunk/gcc/cselib.c:1531
0xbf0837 vt_expand_var_loc_chain
    ../../gcc-trunk/gcc/var-tracking.c:8223
0xbf32fa vt_expand_loc_callback
    ../../gcc-trunk/gcc/var-tracking.c:8385
0x6a565b cselib_expand_value_rtx_1
    ../../gcc-trunk/gcc/cselib.c:1684
0x6a698e cselib_expand_value_rtx_cb(rtx_def*, bitmap_head_def*, int, rtx_def*
(*)(rtx_def*, bitmap_head_def*, int, void*), void*)
    ../../gcc-trunk/gcc/cselib.c:1531
0xbf0837 vt_expand_var_loc_chain
    ../../gcc-trunk/gcc/var-tracking.c:8223
0xbf152f vt_expand_1pvar
    ../../gcc-trunk/gcc/var-tracking.c:8498
0xbf152f emit_note_insn_var_location(variable_def**, emit_note_data_def*)
    ../../gcc-trunk/gcc/var-tracking.c:8552
0xbfc35e traverse_noresize<emit_note_data_def*, emit_note_insn_var_location>
    ../../gcc-trunk/gcc/hash-table.h:928
0xbfc35e traverse<emit_note_data_def*, emit_note_insn_var_location>
    ../../gcc-trunk/gcc/hash-table.h:950
0xbfc35e emit_notes_for_changes
    ../../gcc-trunk/gcc/var-tracking.c:8914
0xbfd09e emit_notes_in_bb
    ../../gcc-trunk/gcc/var-tracking.c:9345
0xbfd09e vt_emit_notes
    ../../gcc-trunk/gcc/var-tracking.c:9408
0xbfda4f variable_tracking_main_1
    ../../gcc-trunk/gcc/var-tracking.c:10206
0xbfda4f variable_tracking_main()
    ../../gcc-trunk/gcc/var-tracking.c:10220
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
$ 


----------------------------


int a, b, c, f, g;

void
fn2 ()
{
  for (; b; b++)
    for (; f; f = g)
      for (; a;)
    ;
}

static int
fn1 (int p)
{
  short d;
  if (c)
    {
      for (; f; f = g);
      fn2 ();
      d = p;
      char e = d;
      if (p)
    return 1;
    }
  return p;
}

int
main ()
{
  fn1 (0);
  fn1 (g);
  return 0;
}

Reply via email to