Hi, > The loop appears to be entered at the top, yet both my original and your test > fail. > > Looking what happens with your test in more detail, I find that > > loop->latch == desc->in_edge->dest > > is true, but forwarder_block_p (loop->latch) fails: > > 562 if (dest->loop_father->header == dest) > (gdb) > 563 return false; > (gdb) p dest > $7 = (basic_block) 0xb7be8198 > (gdb) p dest->loop_father->header > $8 = (basic_block) 0xb7be8198 > > The comment in front of this code says: > /* Protect loop latches, headers and preheaders. */ > > So, presumably, the loop latch will remain a forwarder block precisely because > forwarder_block_p denies that it is one. > > So, may I just write: > entered_at_top = (loop->latch == desc->in_edge->dest);
no -- you should also test that latch contains no active insns. I.e., factorize out whatever forwarder_block_p does except for the test "(dest->loop_father->header == dest)" test, Zdenek