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

            Bug ID: 62208
           Summary: ICE with LTO on valid code at -O3 on x86_64-linux-gnu
                    in trunc_int_for_mode, at explow.c:56
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
          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 with
LTO at -O3 on x86_64-linux-gnu in 32-bit mode (but not in 64-bit mode).

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/5.0.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 5.0.0 20140820 (experimental) [trunk revision 214209] (GCC) 
$ 
$ gcc-trunk -m32 -O3 small.c; a.out
$ gcc-trunk -flto -m64 -O3 small.c; a.out
$ gcc-4.9 -flto -m32 -O3 small.c; a.out
$ 
$ gcc-trunk -flto -m32 -O3 small.c
small.c: In function ‘main’:
small.c:21:1: internal compiler error: in trunc_int_for_mode, at explow.c:56
 }
 ^
0x627bb0 trunc_int_for_mode(long, machine_mode)
    ../../gcc-trunk/gcc/explow.c:56
0x616418 gen_int_mode(long, machine_mode)
    ../../gcc-trunk/gcc/emit-rtl.c:437
0x8d159c simplify_const_unary_operation(rtx_code, machine_mode, rtx_def*,
machine_mode)
    ../../gcc-trunk/gcc/simplify-rtx.c:1735
0x8ceb6a simplify_unary_operation(rtx_code, machine_mode, rtx_def*,
machine_mode)
    ../../gcc-trunk/gcc/simplify-rtx.c:814
0x8cff10 simplify_gen_unary(rtx_code, machine_mode, rtx_def*, machine_mode)
    ../../gcc-trunk/gcc/simplify-rtx.c:387
0xe1249e if_then_else_cond
    ../../gcc-trunk/gcc/combine.c:8615
0xe1d32e combine_simplify_rtx
    ../../gcc-trunk/gcc/combine.c:5262
0xe1fbaa subst
    ../../gcc-trunk/gcc/combine.c:5199
0xe1f8c8 subst
    ../../gcc-trunk/gcc/combine.c:5144
0xe1f8c8 subst
    ../../gcc-trunk/gcc/combine.c:5144
0xe22124 try_combine
    ../../gcc-trunk/gcc/combine.c:3134
0xe27f8d combine_instructions
    ../../gcc-trunk/gcc/combine.c:1280
0xe27f8d rest_of_handle_combine
    ../../gcc-trunk/gcc/combine.c:13896
0xe27f8d execute
    ../../gcc-trunk/gcc/combine.c:13939
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.
lto-wrapper: fatal error: gcc-trunk returned 1 exit status
compilation terminated.
/usr/bin/ld: fatal error: lto-wrapper failed
collect2: error: ld returned 1 exit status
$ 


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


int *a;
unsigned int b;

void fn2 ()
{
  int t[9];
  for (; b; b++)
    *a ^= (~t[b] != t[b]);
}

int fn1 ()
{
  fn2 (); 
  return 0; 
}

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

Reply via email to