There is no need to avoid threading to a loop header, the threading code can cope with this just fine. Noticed when working on PR72772.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk. Richard. 2016-08-05 Richard Biener <rguent...@suse.de> * tree-ssa-threadupdate.c (thread_block_1): Remove unnecessary restriction on threading to a loop header. Index: gcc/tree-ssa-threadupdate.c =================================================================== --- gcc/tree-ssa-threadupdate.c (revision 239117) +++ gcc/tree-ssa-threadupdate.c (working copy) @@ -1531,10 +1531,8 @@ thread_block_1 (basic_block bb, bool nol threading path that crosses loop boundaries. We do not try and thread this elsewhere, so just cancel the jump threading request by clearing the AUX field now. */ - if ((bb->loop_father != e2->src->loop_father - && !loop_exit_edge_p (e2->src->loop_father, e2)) - || (e2->src->loop_father != e2->dest->loop_father - && !loop_exit_edge_p (e2->src->loop_father, e2))) + if (bb->loop_father != e2->src->loop_father + && !loop_exit_edge_p (e2->src->loop_father, e2)) { /* Since this case is not handled by our special code to thread through a loop header, we must explicitly