On Mon, Oct 22, 2012 at 11:09 PM, Jakub Jelinek wrote: > On Mon, Oct 22, 2012 at 10:51:43PM +0200, Steven Bosscher wrote: > Wouldn't it be way cheaper to just export dfs_find_deadend from cfganal.c > and call it in calc_dfs_tree on each unconnected bb? > I.e. (untested with the exception of the testcase): > > 2012-10-22 Jakub Jelinek > > PR tree-optimization/55018 > * cfganal.c (dfs_find_deadend): No longer static. > * basic-block.h (dfs_find_deadend): New prototype. > * dominance.c (calc_dfs_tree): If saw_unconnected, > traverse from dfs_find_deadend of unconnected b > instead of b directly. > > * gcc.dg/torture/pr55018.c: New test. I have no better solution than this for the moment. I thought there was a common DFS machinery in cfganal.c but there are actually many of them, but unfortunately all doing things slightly different. Something for the cleanup list for GCC 4.9... We should use dfs_find_deadend in flow_dfs_compute_reverse_execute also. This results in fewer fake edges created in connect_infinite_loops_to_exit, especially for loops with multiple dead ends. (BTW, connect_infinite_loops_to_exit also connects other reverse-unreachable points in the CFG to EXIT, so that calling add_noreturn_fake_exit_edges and connect_infinite_loops_to_exit is doing a bit of duplicate work -- another thing for the cleanup list...) Attached patch was bootstrapped&tested on {powerpc64,x86_64}-unknown-linux-gnu. OK? Ciao! Steven