Bug 59166 - [4.9 Regression] ICE in simplify_subreg, at simplify-rtx.c:5901 on valid code (at -O1 and above with -g enabled)
Summary: [4.9 Regression] ICE in simplify_subreg, at simplify-rtx.c:5901 on valid code...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.9.0
: P1 normal
Target Milestone: 4.9.0
Assignee: Jakub Jelinek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-18 07:40 UTC by Zhendong Su
Modified: 2013-11-26 20:58 UTC (History)
1 user (show)

See Also:
Host:
Target: x86_64-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-11-18 00:00:00


Attachments
gcc49-pr59166.patch (855 bytes, patch)
2013-11-26 11:55 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zhendong Su 2013-11-18 07:40:32 UTC
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;
}
Comment 1 Richard Biener 2013-11-18 11:31:46 UTC
Confirmed.
Comment 2 Jakub Jelinek 2013-11-26 11:31:16 UTC
Started with r204698.
Comment 3 Jakub Jelinek 2013-11-26 11:35:26 UTC
In *.asmcons we still have correct:
(debug_insn 30 29 31 7 (var_location:HI D#1 (subreg:HI (reg/v:SI 93 [ p ]) 0)) pr59166.c:20 -1
     (nil))
but in *.ira we have:
(debug_insn 30 29 31 7 (var_location:HI D#1 (reg/v:SI 97 [orig:93 p ] [93])) pr59166.c:20 -1
     (nil))
(note the wrong mode).
Comment 4 Jakub Jelinek 2013-11-26 11:55:34 UTC
Created attachment 31297 [details]
gcc49-pr59166.patch

Untested fix.
Comment 5 Jakub Jelinek 2013-11-26 20:54:39 UTC
Author: jakub
Date: Tue Nov 26 20:54:37 2013
New Revision: 205413

URL: http://gcc.gnu.org/viewcvs?rev=205413&root=gcc&view=rev
Log:
	PR rtl-optimization/59166
	* ira.c (find_moveable_pseudos): Use DF_REF_REAL_LOC instead of
	DF_REF_LOC in validate_change call.
	(split_live_ranges_for_shrink_wrap): Likewise.

	* gcc.dg/torture/pr59166.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/torture/pr59166.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/ira.c
    trunk/gcc/testsuite/ChangeLog
Comment 6 Jakub Jelinek 2013-11-26 20:58:02 UTC
Fixed.