aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorKazu Hirata <kazu@cs.umass.edu>2005-02-21 18:38:05 +0000
committerKazu Hirata <kazu@gcc.gnu.org>2005-02-21 18:38:05 +0000
commitfca01525bf39af39d545094e75cb72276f46013c (patch)
tree94ecbbfd3758ca781238f888eea60894968ddc3f /gcc
parent92c91cf7fe57f41771273f941431432c77f76f59 (diff)
downloadgcc-fca01525bf39af39d545094e75cb72276f46013c.zip
gcc-fca01525bf39af39d545094e75cb72276f46013c.tar.gz
gcc-fca01525bf39af39d545094e75cb72276f46013c.tar.bz2
tree-cfg.c (fold_cond_expr_cond): New.
* tree-cfg.c (fold_cond_expr_cond): New. (make_edges): Call fold_cond_expr_cond. (find_taken_edge): Accept nothing but INTEGER_CST. (find_taken_edge_cond_expr): Reject INTEGER_CST other than 0 and 1. (find_taken_edge_switch_expr): Remove a check for INTEGER_CST. From-SVN: r95339
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/tree-cfg.c44
2 files changed, 39 insertions, 14 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 37cf2fb..e18b08a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2005-02-21 Kazu Hirata <kazu@cs.umass.edu>
+
+ * tree-cfg.c (fold_cond_expr_cond): New.
+ (make_edges): Call fold_cond_expr_cond.
+ (find_taken_edge): Accept nothing but INTEGER_CST.
+ (find_taken_edge_cond_expr): Reject INTEGER_CST other than 0
+ and 1.
+ (find_taken_edge_switch_expr): Remove a check for INTEGER_CST.
+
2005-02-21 Jeff Law <law@redhat.com>
* cfganal.c (find_unreachable_blocks): Manually CSE load of
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 680262c..9e87dbf 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -440,6 +440,29 @@ create_bb (void *h, void *e, basic_block after)
Edge creation
---------------------------------------------------------------------------*/
+/* Fold COND_EXPR_COND of each COND_EXPR. */
+
+static void
+fold_cond_expr_cond (void)
+{
+ basic_block bb;
+
+ FOR_EACH_BB (bb)
+ {
+ tree stmt = last_stmt (bb);
+
+ if (stmt
+ && TREE_CODE (stmt) == COND_EXPR)
+ {
+ tree cond = fold (COND_EXPR_COND (stmt));
+ if (integer_zerop (cond))
+ COND_EXPR_COND (stmt) = integer_zero_node;
+ else if (integer_onep (cond))
+ COND_EXPR_COND (stmt) = integer_one_node;
+ }
+ }
+}
+
/* Join all the blocks in the flowgraph. */
static void
@@ -478,6 +501,9 @@ make_edges (void)
builder inserted for completeness. */
remove_fake_exit_edges ();
+ /* Fold COND_EXPR_COND of each COND_EXPR. */
+ fold_cond_expr_cond ();
+
/* Clean up the graph and warn for unreachable code. */
cleanup_tree_cfg ();
}
@@ -2198,14 +2224,7 @@ find_taken_edge (basic_block bb, tree val)
gcc_assert (is_ctrl_stmt (stmt));
gcc_assert (val);
- /* If VAL is a predicate of the form N RELOP N, where N is an
- SSA_NAME, we can usually determine its truth value. */
- if (COMPARISON_CLASS_P (val))
- val = fold (val);
-
- /* If VAL is not a constant, we can't determine which edge might
- be taken. */
- if (!really_constant_p (val))
+ if (TREE_CODE (val) != INTEGER_CST)
return NULL;
if (TREE_CODE (stmt) == COND_EXPR)
@@ -2237,12 +2256,12 @@ find_taken_edge_cond_expr (basic_block bb, tree val)
return true_edge;
else if (integer_zerop (val))
return false_edge;
- else
- return NULL;
+
+ gcc_unreachable ();
}
-/* Given a constant value VAL and the entry block BB to a SWITCH_EXPR
+/* Given an INTEGER_CST VAL and the entry block BB to a SWITCH_EXPR
statement, determine which edge will be taken out of the block. Return
NULL if any edge may be taken. */
@@ -2253,9 +2272,6 @@ find_taken_edge_switch_expr (basic_block bb, tree val)
basic_block dest_bb;
edge e;
- if (TREE_CODE (val) != INTEGER_CST)
- return NULL;
-
switch_expr = last_stmt (bb);
taken_case = find_case_label_for_value (switch_expr, val);
dest_bb = label_to_block (CASE_LABEL (taken_case));