cfgcleanup: Fold jumps and conditional branches with returns
commit01b8ebb6e5940eca6d158dc793424a6580c90998
authorsegher <segher@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 4 May 2016 20:54:47 +0000 (4 20:54 +0000)
committersegher <segher@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 4 May 2016 20:54:47 +0000 (4 20:54 +0000)
tree0b0bd030c7648340a035bf394fa67488d6f390a9
parent0989c8530ce2fc6dc550ce789f2a601b4033e264
cfgcleanup: Fold jumps and conditional branches with returns

This patch makes cfgcleanup optimize jumps to returns.  There are three
cases this handles:

-- A jump to a return; this is simplified to just that return.
-- A conditional branch to a return; simplified to a conditional return.
-- A conditional branch that falls through to a return.  This is simplified
   to a conditional return (with the condition inverted), falling through
   to a jump to the original destination.  That jump can then be optimized
   further, as usual.

This handles all cases the current function.c does, and a few it misses.

* cfgcleanup.c (bb_is_just_return): New function.
(try_optimize_cfg): Simplify jumps to return, branches to return,
and branches around return.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@235904 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/cfgcleanup.c