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

--- Comment #5 from Tom de Vries <vries at gcc dot gnu.org> ---
There actually is some code in find_same_succ_bb to keep loop structure:
...
  if (bb == NULL
      /* Be conservative with loop structure.  It's not evident that this test  
         is sufficient.  Before tail-merge, we've just called                   
         loop_optimizer_finalize, and LOOPS_MAY_HAVE_MULTIPLE_LATCHES is now    
         set, so there's no guarantee that the loop->latch value is still
valid.                      
         But we assume that, since we've forced LOOPS_HAVE_SIMPLE_LATCHES at
the                      
         start of pre, we've kept that property intact throughout pre, and are  
         keeping it throughout tail-merge using this test.  */
      || bb->loop_father->latch == bb)
    return;
...

For this example, the cleanup_tree_cfg in tail_merge_optimize creates multiple
loop latches in the inner loop, so the loop->latch value is no longer valid.
This test needs fixing.

Reply via email to