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

            Bug ID: 69574
           Summary: gcc ICE at -O2 and -O3 on x86_64-linux-gnu in
                    hide_evolution_in_other_loops_than_loop
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: helloqirun at gmail dot com
  Target Milestone: ---

The following valid 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.


The -O2 part might be a regression from 4.8.2, and the -O3 part is a 6
regression.




$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/home/absozero/trunk/root-gcc/libexec/gcc/x86_64-pc-linux-gnu/6.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --prefix=/home/absozero/trunk/root-gcc
--enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
gcc version 6.0.0 20160130 (experimental) [trunk revision 233007] (GCC)



$ gcc-trunk -O3 -c abc.c
abc.c: In function 'fn1':
abc.c:5:6: internal compiler error: in hide_evolution_in_other_loops_than_loop,
at tree-chrec.c:733
 void fn1() {
      ^~~
0x129b1b4 hide_evolution_in_other_loops_than_loop(tree_node*, unsigned int)
        ../../gcc/gcc/tree-chrec.c:733
0xc32c41 no_evolution_in_loop_p
        ../../gcc/gcc/tree-chrec.h:122
0xc32c41 build_polynomial_chrec
        ../../gcc/gcc/tree-chrec.h:140
0xc366b0 instantiate_scev_poly
        ../../gcc/gcc/tree-scalar-evolution.c:2434
0xc366b0 instantiate_scev_r
        ../../gcc/gcc/tree-scalar-evolution.c:2803
0xc365a5 instantiate_scev_convert
        ../../gcc/gcc/tree-scalar-evolution.c:2560
0xc365a5 instantiate_scev_r
        ../../gcc/gcc/tree-scalar-evolution.c:2820
0xc365a5 instantiate_scev_convert
        ../../gcc/gcc/tree-scalar-evolution.c:2560
0xc365a5 instantiate_scev_r
        ../../gcc/gcc/tree-scalar-evolution.c:2820
0xc373b5 instantiate_scev(basic_block_def*, loop*, tree_node*)
        ../../gcc/gcc/tree-scalar-evolution.c:2907
0xcc0d25 instantiate_parameters
        ../../gcc/gcc/tree-scalar-evolution.h:60
0xcc0d25 idx_infer_loop_bounds
        ../../gcc/gcc/tree-ssa-loop-niter.c:3133
0xcc7e58 for_each_index(tree_node**, bool (*)(tree_node*, tree_node**, void*),
void*)
        ../../gcc/gcc/tree-ssa-loop.c:658
0xcbece7 infer_loop_bounds_from_ref
        ../../gcc/gcc/tree-ssa-loop-niter.c:3208
0xcbece7 infer_loop_bounds_from_array
        ../../gcc/gcc/tree-ssa-loop-niter.c:3229
0xcbece7 infer_loop_bounds_from_undefined
        ../../gcc/gcc/tree-ssa-loop-niter.c:3381
0xcbece7 estimate_numbers_of_iterations_loop
        ../../gcc/gcc/tree-ssa-loop-niter.c:3752
0xcc0214 estimate_numbers_of_iterations()
        ../../gcc/gcc/tree-ssa-loop-niter.c:3920
0xcc6f40 execute
        ../../gcc/gcc/tree-ssa-loop.c:500
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.



$ cat abc.c
int a;
char d;
volatile int e;
int f[1][1][8];
void fn1() {
  int k;
l1:
  for (;;) {
    d = 0;
    for (; e; d--)
      for (; k; a = 9) {
        if (a)
          goto l1;
        for (; e; d--)
          a = f[a][d][a] ?: a;
      }
  }
}

Reply via email to