aboutsummaryrefslogtreecommitdiff
path: root/gcc/ipa-split.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2011-01-19 20:58:37 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2011-01-19 20:58:37 +0100
commit6845790106547205986fc58987d5bd4662d03e1c (patch)
treea6b7079dc0c7cf2bfa1ad869ea121d438e54d9eb /gcc/ipa-split.c
parented7656f693dfbf3e69bf1d05a8c69dca31908200 (diff)
downloadgcc-6845790106547205986fc58987d5bd4662d03e1c.zip
gcc-6845790106547205986fc58987d5bd4662d03e1c.tar.gz
gcc-6845790106547205986fc58987d5bd4662d03e1c.tar.bz2
ipa-split.c (find_return_bb): Use single_pred_p/single_pred_edge, simplify.
* ipa-split.c (find_return_bb): Use single_pred_p/single_pred_edge, simplify. From-SVN: r169020
Diffstat (limited to 'gcc/ipa-split.c')
-rw-r--r--gcc/ipa-split.c68
1 files changed, 30 insertions, 38 deletions
diff --git a/gcc/ipa-split.c b/gcc/ipa-split.c
index d5bf35f..c72a36d 100644
--- a/gcc/ipa-split.c
+++ b/gcc/ipa-split.c
@@ -496,47 +496,39 @@ static basic_block
find_return_bb (void)
{
edge e;
- edge_iterator ei;
basic_block return_bb = EXIT_BLOCK_PTR;
+ gimple_stmt_iterator bsi;
+ bool found_return = false;
+ tree retval = NULL_TREE;
- if (EDGE_COUNT (EXIT_BLOCK_PTR->preds) == 1)
- FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds)
- {
- gimple_stmt_iterator bsi;
- bool found_return = false;
- tree retval = NULL_TREE;
+ if (!single_pred_p (EXIT_BLOCK_PTR))
+ return return_bb;
+
+ e = single_pred_edge (EXIT_BLOCK_PTR);
+ for (bsi = gsi_last_bb (e->src); !gsi_end_p (bsi); gsi_prev (&bsi))
+ {
+ gimple stmt = gsi_stmt (bsi);
+ if (gimple_code (stmt) == GIMPLE_LABEL || is_gimple_debug (stmt))
+ ;
+ else if (gimple_code (stmt) == GIMPLE_ASSIGN
+ && found_return
+ && gimple_assign_single_p (stmt)
+ && (auto_var_in_fn_p (gimple_assign_rhs1 (stmt),
+ current_function_decl)
+ || is_gimple_min_invariant (gimple_assign_rhs1 (stmt)))
+ && retval == gimple_assign_lhs (stmt))
+ ;
+ else if (gimple_code (stmt) == GIMPLE_RETURN)
+ {
+ found_return = true;
+ retval = gimple_return_retval (stmt);
+ }
+ else
+ break;
+ }
+ if (gsi_end_p (bsi) && found_return)
+ return_bb = e->src;
- for (bsi = gsi_last_bb (e->src); !gsi_end_p (bsi); gsi_prev (&bsi))
- {
- gimple stmt = gsi_stmt (bsi);
- if (gimple_code (stmt) == GIMPLE_LABEL
- || is_gimple_debug (stmt))
- ;
- else if (gimple_code (stmt) == GIMPLE_ASSIGN
- && found_return
- && gimple_assign_single_p (stmt)
- && (auto_var_in_fn_p (gimple_assign_rhs1 (stmt),
- current_function_decl)
- || is_gimple_min_invariant
- (gimple_assign_rhs1 (stmt)))
- && retval == gimple_assign_lhs (stmt))
- ;
- else if (gimple_code (stmt) == GIMPLE_RETURN)
- {
- found_return = true;
- retval = gimple_return_retval (stmt);
- }
- else
- break;
- }
- if (gsi_end_p (bsi) && found_return)
- {
- if (retval)
- return e->src;
- else
- return_bb = e->src;
- }
- }
return return_bb;
}