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

            Bug ID: 80539
           Summary: gcc ICE at -O2 and above on valid code on
                    x86_64-linux-gnu in "chrec_fold_plus_poly_poly"
           Product: gcc
           Version: 8.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 above on x86_64-linux-gnu in both 32- and 64-bit modes. 


$ gcc-trunk --version
gcc-trunk (GCC) 8.0.0 20170426 (experimental) [trunk revision 247284]
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.



$ gcc-trunk -O2 abc.c
abc.c: In function ‘fn1’:
abc.c:2:6: internal compiler error: in chrec_fold_plus_poly_poly, at
tree-chrec.c:152
 void fn1() {
      ^~~
0x1373a17 chrec_fold_plus_poly_poly
        ../../gcc/gcc/tree-chrec.c:152
0x1373a17 chrec_fold_plus_1
        ../../gcc/gcc/tree-chrec.c:285
0xc744fb interpret_rhs_expr
        ../../gcc/gcc/tree-scalar-evolution.c:1839
0xc7117c interpret_gimple_assign
        ../../gcc/gcc/tree-scalar-evolution.c:2008
0xc7117c analyze_scalar_evolution_1
        ../../gcc/gcc/tree-scalar-evolution.c:2092
0xc71a5e analyze_scalar_evolution(loop*, tree_node*)
        ../../gcc/gcc/tree-scalar-evolution.c:2147
0xc74c4a interpret_rhs_expr
        ../../gcc/gcc/tree-scalar-evolution.c:1935
0xc7117c interpret_gimple_assign
        ../../gcc/gcc/tree-scalar-evolution.c:2008
0xc7117c analyze_scalar_evolution_1
        ../../gcc/gcc/tree-scalar-evolution.c:2092
0xc71a5e analyze_scalar_evolution(loop*, tree_node*)
        ../../gcc/gcc/tree-scalar-evolution.c:2147
0xcfc269 infer_loop_bounds_from_signedness
        ../../gcc/gcc/tree-ssa-loop-niter.c:3412
0xcfc269 infer_loop_bounds_from_undefined
        ../../gcc/gcc/tree-ssa-loop-niter.c:3469
0xcfc269 estimate_numbers_of_iterations_loop
        ../../gcc/gcc/tree-ssa-loop-niter.c:3852
0xcfce13 estimate_numbers_of_iterations()
        ../../gcc/gcc/tree-ssa-loop-niter.c:4065
0xcd4479 tree_unroll_loops_completely(bool, bool)
        ../../gcc/gcc/tree-ssa-loop-ivcanon.c:1369
0xcd4b35 execute
        ../../gcc/gcc/tree-ssa-loop-ivcanon.c:1586
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.



$ cat abc.c
char a, b;
void fn1() {
  char c, e;
  short d;
  if (0) {
    for (; d;) {
    l1:
      for (c = 7; a; c++)
        ;
      e = 6;
      for (; b; e++)
        ;
    }
    c -= e;
  }
  if (d == 7)
    goto l1;
  a = c;
}

Reply via email to