aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Novillo <dnovillo@redhat.com>2004-07-12 15:38:25 +0000
committerDiego Novillo <dnovillo@gcc.gnu.org>2004-07-12 11:38:25 -0400
commit255cd731f40dd7b5855e0bc12a9cdd6383e65321 (patch)
tree028ad72a48dbd069536dd663bdf97b2074816a1c
parent938bf7475d34bb808144dff4ea0903026bd70b28 (diff)
downloadgcc-255cd731f40dd7b5855e0bc12a9cdd6383e65321.zip
gcc-255cd731f40dd7b5855e0bc12a9cdd6383e65321.tar.gz
gcc-255cd731f40dd7b5855e0bc12a9cdd6383e65321.tar.bz2
tree-cfg.c (find_taken_edge): Statically compute the truth value of a predicate comparing an SSA_NAME to itself.
* tree-cfg.c (find_taken_edge): Statically compute the truth value of a predicate comparing an SSA_NAME to itself. From-SVN: r84561
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/tree-cfg.c24
2 files changed, 26 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e3d670d..9580f3d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2004-07-12 Diego Novillo <dnovillo@redhat.com>
+
+ * tree-cfg.c (find_taken_edge): Statically compute the truth
+ value of a predicate comparing an SSA_NAME to itself.
+
2004-07-12 Roger Sayle <roger@eyesopen.com>
* config/rs6000/rs6000.c (rs6000_rtx_costs): Indicate that the
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index bd2ec9a..6207fd3 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -1991,9 +1991,9 @@ cleanup_control_expr_graph (basic_block bb, block_stmt_iterator bsi)
}
-/* Given a control block BB and a constant value VAL, return the edge that
- will be taken out of the block. If VAL does not match a unique edge,
- NULL is returned. */
+/* Given a control block BB and a predicate VAL, return the edge that
+ will be taken out of the block. If VAL does not match a unique
+ edge, NULL is returned. */
edge
find_taken_edge (basic_block bb, tree val)
@@ -2007,6 +2007,24 @@ find_taken_edge (basic_block bb, tree val)
abort ();
#endif
+ /* If VAL is a predicate of the form N RELOP N, where N is an
+ SSA_NAME, we can always determine its truth value (except when
+ doing floating point comparisons that may involve NaNs). */
+ if (val
+ && TREE_CODE_CLASS (TREE_CODE (val)) == '<'
+ && TREE_OPERAND (val, 0) == TREE_OPERAND (val, 1)
+ && TREE_CODE (TREE_OPERAND (val, 0)) == SSA_NAME
+ && (TREE_CODE (TREE_TYPE (TREE_OPERAND (val, 0))) != REAL_TYPE
+ || !HONOR_NANS (TYPE_MODE (TREE_TYPE (TREE_OPERAND (val, 0))))))
+ {
+ enum tree_code code = TREE_CODE (val);
+
+ if (code == EQ_EXPR || code == LE_EXPR || code == GE_EXPR)
+ val = boolean_true_node;
+ else if (code == LT_EXPR || code == GT_EXPR || code == NE_EXPR)
+ val = boolean_false_node;
+ }
+
/* If VAL is not a constant, we can't determine which edge might
be taken. */
if (val == NULL || !really_constant_p (val))