aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Pinski <apinski@cavium.com>2012-05-16 20:22:03 +0000
committerAndrew Pinski <pinskia@gcc.gnu.org>2012-05-16 13:22:03 -0700
commit763dc99dd311306c8c140e188f9be4bddb3dbc0c (patch)
tree367528823c752fbc5fb3617b3bf2902eafce4aa2
parent0e2b0f75cc7541b82abcb78494f20402b89e13b6 (diff)
downloadgcc-763dc99dd311306c8c140e188f9be4bddb3dbc0c.zip
gcc-763dc99dd311306c8c140e188f9be4bddb3dbc0c.tar.gz
gcc-763dc99dd311306c8c140e188f9be4bddb3dbc0c.tar.bz2
gimple-fold.c (get_maxval_strlen): Move COND_EXPR handling under GIMPLE_ASSIGN.
2012-05-16 Andrew Pinski <apinski@cavium.com> * gimple-fold.c (get_maxval_strlen): Move COND_EXPR handling under GIMPLE_ASSIGN. From-SVN: r187608
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/gimple-fold.c16
2 files changed, 15 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6715f30..b05a5b5 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2012-05-16 Andrew Pinski <apinski@cavium.com>
+
+ * gimple-fold.c (get_maxval_strlen): Move COND_EXPR handling under
+ GIMPLE_ASSIGN.
+
2012-05-16 David S. Miller <davem@davemloft.net>
* jump.c (delete_related_insns): If we remove a CALL, make sure
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index ee8b4d1..b6f0143 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -670,13 +670,10 @@ get_maxval_strlen (tree arg, tree *length, bitmap visited, int type)
if (TREE_CODE (arg) != SSA_NAME)
{
- if (TREE_CODE (arg) == COND_EXPR)
- return get_maxval_strlen (COND_EXPR_THEN (arg), length, visited, type)
- && get_maxval_strlen (COND_EXPR_ELSE (arg), length, visited, type);
/* We can end up with &(*iftmp_1)[0] here as well, so handle it. */
- else if (TREE_CODE (arg) == ADDR_EXPR
- && TREE_CODE (TREE_OPERAND (arg, 0)) == ARRAY_REF
- && integer_zerop (TREE_OPERAND (TREE_OPERAND (arg, 0), 1)))
+ if (TREE_CODE (arg) == ADDR_EXPR
+ && TREE_CODE (TREE_OPERAND (arg, 0)) == ARRAY_REF
+ && integer_zerop (TREE_OPERAND (TREE_OPERAND (arg, 0), 1)))
{
tree aop0 = TREE_OPERAND (TREE_OPERAND (arg, 0), 0);
if (TREE_CODE (aop0) == INDIRECT_REF
@@ -736,6 +733,13 @@ get_maxval_strlen (tree arg, tree *length, bitmap visited, int type)
tree rhs = gimple_assign_rhs1 (def_stmt);
return get_maxval_strlen (rhs, length, visited, type);
}
+ else if (gimple_assign_rhs_code (def_stmt) == COND_EXPR)
+ {
+ tree op2 = gimple_assign_rhs2 (def_stmt);
+ tree op3 = gimple_assign_rhs3 (def_stmt);
+ return get_maxval_strlen (op2, length, visited, type)
+ && get_maxval_strlen (op3, length, visited, type);
+ }
return false;
case GIMPLE_PHI: