------- Additional Comments From law at redhat dot com 2005-02-14 20:01 ------- The new jump thread selection code handles this properly.
I will note that your comments about the code we ought to be able to generate are wrong. The correctly optimized code should look like this: (note the difference in where we test c == 3. foo (a, b, c) { # BLOCK 0 # PRED: ENTRY [100.0%] (fallthru,exec) if (a_1 == 1) goto <L3>; else goto <L0>; # SUCC: 3 [14.9%] (true,exec) 1 [85.1%] (false,exec) # BLOCK 1 # PRED: 0 [85.1%] (false,exec) <L0>:; if (b_3 == 2) goto <L2>; else goto <L5>; # SUCC: 2 [45.3%] (true,exec) 5 [54.7%] (false,exec) # BLOCK 2 # PRED: 1 [45.3%] (true,exec) <L2>:; if (c_2 == 3) goto <L3>; else goto <L4>; # SUCC: 3 [48.8%] (true,exec) 4 [51.2%] (false,exec) # BLOCK 3 # PRED: 0 [14.9%] (true,exec) 2 [48.8%] (true,exec) <L3>:; f1 (); goto <bb 5> (<L5>); # SUCC: 5 [100.0%] (fallthru,exec) # BLOCK 4 # PRED: 2 [51.2%] (false,exec) <L4>:; f2 (); # SUCC: 5 [100.0%] (fallthru,exec) # BLOCK 5 # PRED: 1 [54.7%] (false,exec) 3 [100.0%] (fallthru,exec) 4 [100.0%] (fallthru,exec) <L5>:; return; -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15352