Bug 61222 - [4.10 Regression] ICE on valid code at -O2 and -O3 on x86_64-linux-gnu in decompose, at rtl.h:1456
Summary: [4.10 Regression] ICE on valid code at -O2 and -O3 on x86_64-linux-gnu in dec...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 5.0
: P3 normal
Target Milestone: 5.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 61224 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-05-19 01:02 UTC by Zhendong Su
Modified: 2014-05-27 18:54 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2014-05-19 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zhendong Su 2014-05-19 01:02:16 UTC
The following code causes an ICE when compiled with the current gcc trunk at -O2 and -O3 on x86_64-linux-gnu in both 32-bit and 64-bit modes.

It is a regression from 4.9.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.10.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure --prefix=/usr/local/gcc-trunk --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
gcc version 4.10.0 20140518 (experimental) [trunk revision 210581] (GCC) 
$ 
$ gcc-trunk -Os small.c; a.out
$ gcc-4.9.0 -O2 small.c; a.out
$ 
$ gcc-trunk -O2 small.c
small.c: In function ‘foo’:
small.c:16:1: internal compiler error: in decompose, at rtl.h:1456
 }
 ^
0x9725a8 wi::int_traits<std::pair<rtx_def*, machine_mode> >::decompose(long*, unsigned int, std::pair<rtx_def*, machine_mode> const&)
	../../gcc-trunk/gcc/rtl.h:1454
0x96ade9 wi::int_traits<std::pair<rtx_def*, machine_mode> >::decompose(long*, unsigned int, std::pair<rtx_def*, machine_mode> const&)
	../../gcc-trunk/gcc/rtl.h:1454
0x96ade9 wide_int_ref_storage<std::pair<rtx_def*, machine_mode> >
	../../gcc-trunk/gcc/wide-int.h:959
0x96ade9 generic_wide_int<std::pair<rtx_def*, machine_mode> >
	../../gcc-trunk/gcc/wide-int.h:735
0x96ade9 sub<std::pair<rtx_def*, machine_mode>, std::pair<rtx_def*, machine_mode> >
	../../gcc-trunk/gcc/wide-int.h:2349
0x96ade9 simplify_const_binary_operation(rtx_code, machine_mode, rtx_def*, rtx_def*)
	../../gcc-trunk/gcc/simplify-rtx.c:3732
0xe6d2eb simplify_shift_const_1
	../../gcc-trunk/gcc/combine.c:10352
0xe6d625 simplify_shift_const
	../../gcc-trunk/gcc/combine.c:10526
0xe7567d combine_simplify_rtx
	../../gcc-trunk/gcc/combine.c:5873
0xe77a8a subst
	../../gcc-trunk/gcc/combine.c:5170
0xe752ab combine_simplify_rtx
	../../gcc-trunk/gcc/combine.c:5250
0xe77a8a subst
	../../gcc-trunk/gcc/combine.c:5170
0xe777a8 subst
	../../gcc-trunk/gcc/combine.c:5115
0xe777a8 subst
	../../gcc-trunk/gcc/combine.c:5115
0xe777a8 subst
	../../gcc-trunk/gcc/combine.c:5115
0xe78d7e try_combine
	../../gcc-trunk/gcc/combine.c:3138
0xe7eab3 combine_instructions
	../../gcc-trunk/gcc/combine.c:1370
0xe7eab3 rest_of_handle_combine
	../../gcc-trunk/gcc/combine.c:13865
0xe7eab3 execute
	../../gcc-trunk/gcc/combine.c:13909
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, d, e;
char c;

void
foo ()
{
  for (; a; a++)
    {
      d = ((b == 0) ^ (129 + a));
      c = d * 9;
      e = c < 1;
      if (e)
	for (;;)
	  ;
    }
}

int
main ()
{
  foo (); 
  return 0;
}
Comment 1 Richard Biener 2014-05-19 10:29:13 UTC
Confirmed.
Comment 2 Jakub Jelinek 2014-05-19 17:42:50 UTC
Caused by wide-int merge: r210113.
Comment 3 Richard Sandiford 2014-05-19 18:35:18 UTC
*** Bug 61224 has been marked as a duplicate of this bug. ***
Comment 4 Richard Sandiford 2014-05-19 18:35:58 UTC
Combine is getting confused about which mode it's using.
Comment 5 Richard Sandiford 2014-05-26 18:51:26 UTC
Author: rsandifo
Date: Mon May 26 18:50:55 2014
New Revision: 210945

URL: http://gcc.gnu.org/viewcvs?rev=210945&root=gcc&view=rev
Log:
gcc/
	PR rtl-optimization/61222
	* combine.c (simplify_shift_const_1): When moving a PLUS outside
	the shift, truncate the PLUS operand to the result mode.

gcc/testsuite/
	PR rtl-optimization/61222
	* gcc.c-torture/compile/pr61222-1.c: New test.
	* gcc.c-torture/compile/pr61222-2.c: Likewise.

Added:
    trunk/gcc/testsuite/gcc.c-torture/compile/pr61222-1.c
    trunk/gcc/testsuite/gcc.c-torture/compile/pr61222-2.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/combine.c
    trunk/gcc/testsuite/ChangeLog
Comment 6 Richard Sandiford 2014-05-27 18:54:19 UTC
Fixed on trunk.