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

            Bug ID: 86232
           Summary: ICE in record_estimate, at tree-ssa-loop-niter.c:3258
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sirl at gcc dot gnu.org
  Target Milestone: ---

This short creduced snippet

enum { a = 1 } b;
int c() {
  int d = a;
  for (; d;)
    d &= d - 1;
  return b;
}

compiled with "gcc-9 -c -W -Wall -O2 test-loop-ICE.c" produces this ICE:

during GIMPLE pass: cddce
test-loop-ICE.c: In function 'c':
test-loop-ICE.c:7:1: internal compiler error: in record_estimate, at
tree-ssa-loop-niter.c:3258
 }
 ^
0x850415 record_estimate
        ../../gcc/tree-ssa-loop-niter.c:3258
0x11a3ddc estimate_numbers_of_iterations(loop*)
        ../../gcc/tree-ssa-loop-niter.c:4109
0x11a9dc0 max_loop_iterations(loop*,
generic_wide_int<fixed_wide_int_storage<192> >*)
        ../../gcc/tree-ssa-loop-niter.c:4181
0x11a9dc0 finite_loop_p(loop*)
        ../../gcc/tree-ssa-loop-niter.c:2714
0x1171c3d find_obviously_necessary_stmts
        ../../gcc/tree-ssa-dce.c:420
0x1171c3d perform_tree_ssa_dce
        ../../gcc/tree-ssa-dce.c:1555
0x1171c3d tree_ssa_cd_dce
        ../../gcc/tree-ssa-dce.c:1612
0x1171c3d execute
        ../../gcc/tree-ssa-dce.c:1677

This is a recent regression between r261589 and r261688, still present in
r261783.
The backtrace with the original source looks different, but ends up in the same
place:
during GIMPLE pass: cunrolli
test-loop-ICE-full.cpp: In member function 'void MyClass12::initState()':
test-loop-ICE-full.cpp:246:6: internal compiler error: in record_estimate, at
tree-ssa-loop-niter.c:3258
 void MyClass12::initState()
      ^~~~~~~~~
0x9620d5 record_estimate
        ../../gcc/tree-ssa-loop-niter.c:3258
0x13b093c estimate_numbers_of_iterations(loop*)
        ../../gcc/tree-ssa-loop-niter.c:4109
0x13b8502 estimate_numbers_of_iterations(function*)
        ../../gcc/tree-ssa-loop-niter.c:4329
0x16922f6 tree_unroll_loops_completely
        ../../gcc/tree-ssa-loop-ivcanon.c:1441
0x139c7ae execute
        ../../gcc/tree-ssa-loop-ivcanon.c:1668

Reply via email to