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

            Bug ID: 66357
           Summary: ICE on valid code at -O1, -O2 and -O3 on
                    x86_64-linux-gnu in verify_loop_structure, at
                    cfgloop.c:1662
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: su at cs dot ucdavis.edu
  Target Milestone: ---

The following code causes an ICE when compiled with the current gcc trunk at
-O1, -O2 and -O3 on x86_64-linux-gnu in both 32-bit and 64-bit modes. 

It is a regression from 5.1.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/6.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 6.0.0 20150531 (experimental) [trunk revision 223897] (GCC) 
$ 
$ gcc-trunk -O0 -c small.c
$ gcc-trunk -Os -c small.c
$ gcc-5.1 -O1 -c small.c
$ 
$ gcc-trunk -O1 -c small.c
small.c: In function ‘fn1’:
small.c:5:1: error: size of loop 1 should be 3, not 2
 fn1 ()
 ^
small.c:5:1: error: bb 16 does not belong to loop 1
small.c:5:1: error: bb 17 does not belong to loop 1
small.c:5:1: error: bb 11 does not belong to loop 1
small.c:5:1: error: loop 1’s header does not belong directly to it
small.c:5:1: internal compiler error: in verify_loop_structure, at
cfgloop.c:1662
0x6f4b85 verify_loop_structure()
        ../../gcc-trunk/gcc/cfgloop.c:1662
0x9929e0 fix_loop_structure(bitmap_head*)
        ../../gcc-trunk/gcc/loop-init.c:344
0xb3a5ac repair_loop_structures
        ../../gcc-trunk/gcc/tree-cfgcleanup.c:784
0xb3a5ac cleanup_tree_cfg()
        ../../gcc-trunk/gcc/tree-cfgcleanup.c:814
0xa314d4 execute_function_todo
        ../../gcc-trunk/gcc/passes.c:1899
0xa31d73 execute_todo
        ../../gcc-trunk/gcc/passes.c:2003
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, c, e, f;
volatile int d;

void
fn1 ()
{
  if (!e)
    for (; a; a++)
      {
        if (e)
          for (d++; d;)
            ;
        else
          for (c = 0; c; --c)
            ;
        if (f)
          for (;;)
            {
              if (e)
                break;
              a = 0;
            }
      }
}

Reply via email to