This fixes a wrong-code case after my IPA split fix (with PR68672 still unfixed).
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk. Richard. 2015-12-10 Richard Biener <rguent...@suse.de> PR ipa/68721 * ipa-split.c (split_function): Record return value properly when the split part doesn't set it. * gcc.dg/torture/pr68721.c: New testcase. Index: gcc/ipa-split.c =================================================================== --- gcc/ipa-split.c (revision 231396) +++ gcc/ipa-split.c (working copy) @@ -1281,7 +1281,7 @@ split_function (basic_block return_bb, s to return void instead of just outputting function with undefined return value. For structures this affects quality of codegen. */ else if (!split_point->split_part_set_retval - && find_retval (return_bb)) + && (retval = find_retval (return_bb))) { bool redirected = true; basic_block new_return_bb = create_basic_block (NULL, 0, return_bb); @@ -1305,6 +1305,7 @@ split_function (basic_block return_bb, s e->count = new_return_bb->count; add_bb_to_loop (new_return_bb, current_loops->tree_root); bitmap_set_bit (split_point->split_bbs, new_return_bb->index); + retbnd = find_retbnd (return_bb); } /* When we pass around the value, use existing return block. */ else Index: gcc/testsuite/gcc.dg/torture/pr68721.c =================================================================== --- gcc/testsuite/gcc.dg/torture/pr68721.c (revision 0) +++ gcc/testsuite/gcc.dg/torture/pr68721.c (working copy) @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +extern void abort (void); + +int a, b, c, *d, **e = &d; + +int * +fn1 () +{ + for (;;) + { + for (; a;) + if (b) + abort (); + break; + } + for (; c;) + ; + return &a; +} + +int +main () +{ + *e = fn1 (); + + if (!d) + abort (); + + return 0; +}