aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Berlin <dberlin@dberlin.org>2008-07-15 23:50:52 +0000
committerDaniel Berlin <dberlin@gcc.gnu.org>2008-07-15 23:50:52 +0000
commit2dfb6ce12f3e9c84d406aa0bba68406eba3f0ce0 (patch)
tree4faecb181c40f295369ac919f9ab5203eed115d8
parent15e38d0dce922e77304932817a10f1f42579553f (diff)
downloadgcc-2dfb6ce12f3e9c84d406aa0bba68406eba3f0ce0.zip
gcc-2dfb6ce12f3e9c84d406aa0bba68406eba3f0ce0.tar.gz
gcc-2dfb6ce12f3e9c84d406aa0bba68406eba3f0ce0.tar.bz2
tree-ssa-sccvn.c (expressions_equal_p): Check type equality.
2008-07-15 Daniel Berlin <dberlin@dberlin.org> * tree-ssa-sccvn.c (expressions_equal_p): Check type equality. * tree-ssa-pre.c (pre_expr_eq): Ditto (get_constant_for_value_id): Take a type as an argument. (fully_constant_expression): Pass in type. (find_or_generate_expression): Short circuit constant case. (create_expression_by_pieces): Remove special casing of pointer_plus. (do_regular_insertion): Short circuit constant case. (do_partial_partial_insertion): Ditto. From-SVN: r137859
-rw-r--r--gcc/ChangeLog12
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/20080704-1.c2
-rw-r--r--gcc/tree-ssa-pre.c77
-rw-r--r--gcc/tree-ssa-sccvn.c2
4 files changed, 67 insertions, 26 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index cbb23ea..4c7a776 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,15 @@
+2008-07-15 Daniel Berlin <dberlin@dberlin.org>
+
+ * tree-ssa-sccvn.c (expressions_equal_p): Check type equality.
+ * tree-ssa-pre.c (pre_expr_eq): Ditto
+ (get_constant_for_value_id): Take a type as an argument.
+ (fully_constant_expression): Pass in type.
+ (find_or_generate_expression): Short circuit constant case.
+ (create_expression_by_pieces): Remove special casing of
+ pointer_plus.
+ (do_regular_insertion): Short circuit constant case.
+ (do_partial_partial_insertion): Ditto.
+
2008-07-15 Kaz Kojima <kkojima@gcc.gnu.org>
PR target/36782
diff --git a/gcc/testsuite/gcc.c-torture/compile/20080704-1.c b/gcc/testsuite/gcc.c-torture/compile/20080704-1.c
index 9ca457c..b5e38b4 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20080704-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20080704-1.c
@@ -1,5 +1,5 @@
/* This code used to crash fold_convert due to PRE
- wanting to fold_convert from a REA_TYPE to an INTEGER_TYPE. */
+ wanting to fold_convert from a REAL_TYPE to an INTEGER_TYPE. */
typedef unsigned int uint32_t;
union double_union
{
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
index 07290bc..efa934f 100644
--- a/gcc/tree-ssa-pre.c
+++ b/gcc/tree-ssa-pre.c
@@ -193,8 +193,13 @@ pre_expr_eq (const void *p1, const void *p2)
switch (e1->kind)
{
case CONSTANT:
- return expressions_equal_p (PRE_EXPR_CONSTANT (e1),
- PRE_EXPR_CONSTANT (e2));
+ {
+ tree const0 = PRE_EXPR_CONSTANT (e1);
+ tree const1 = PRE_EXPR_CONSTANT (e2);
+ return TREE_TYPE (const1) == TREE_TYPE (const0)
+ && expressions_equal_p (const0, const1);
+ }
+ break;
case NAME:
return PRE_EXPR_NAME (e1) == PRE_EXPR_NAME (e2);
case NARY:
@@ -316,8 +321,9 @@ get_or_alloc_expr_for_name (tree name)
result_id = lookup_expression_id (result);
if (result_id != 0)
{
- pool_free (pre_expr_pool, result);
- result = expression_for_id (result_id);
+ pre_expr newresult = expression_for_id (result_id);
+ pool_free (pre_expr_pool, result);
+ result = newresult;
return result;
}
get_or_alloc_expression_id (result);
@@ -994,8 +1000,9 @@ get_or_alloc_expr_for_constant (tree constant)
result_id = lookup_expression_id (newexpr);
if (result_id != 0)
{
- pool_free (pre_expr_pool, newexpr);
- newexpr = expression_for_id (result_id);
+ pre_expr newresult = expression_for_id (result_id);
+ pool_free (pre_expr_pool, newexpr);
+ newexpr = newresult;
return newexpr;
}
value_id = get_or_alloc_constant_value_id (constant);
@@ -1009,7 +1016,7 @@ get_or_alloc_expr_for_constant (tree constant)
a constant. */
static tree
-get_constant_for_value_id (unsigned int v)
+get_constant_for_value_id (unsigned int v, tree type)
{
if (value_id_constant_p (v))
{
@@ -1020,7 +1027,8 @@ get_constant_for_value_id (unsigned int v)
FOR_EACH_EXPR_ID_IN_SET (exprset, i, bi)
{
pre_expr expr = expression_for_id (i);
- if (expr->kind == CONSTANT)
+ if (expr->kind == CONSTANT
+ && TREE_TYPE (PRE_EXPR_CONSTANT (expr)) == type)
return PRE_EXPR_CONSTANT (expr);
}
}
@@ -1064,8 +1072,10 @@ fully_constant_expression (pre_expr e)
pre_expr rep1 = get_or_alloc_expr_for (naryop1);
unsigned int vrep0 = get_expr_value_id (rep0);
unsigned int vrep1 = get_expr_value_id (rep1);
- tree const0 = get_constant_for_value_id (vrep0);
- tree const1 = get_constant_for_value_id (vrep1);
+ tree const0 = get_constant_for_value_id (vrep0,
+ TREE_TYPE (nary->op[0]));
+ tree const1 = get_constant_for_value_id (vrep1,
+ TREE_TYPE (nary->op[1]));
tree result = NULL;
if (const0 && const1)
{
@@ -1087,7 +1097,8 @@ fully_constant_expression (pre_expr e)
tree naryop0 = nary->op[0];
pre_expr rep0 = get_or_alloc_expr_for (naryop0);
unsigned int vrep0 = get_expr_value_id (rep0);
- tree const0 = get_constant_for_value_id (vrep0);
+ tree const0 = get_constant_for_value_id (vrep0,
+ TREE_TYPE (nary->op[0]));
tree result = NULL;
if (const0)
{
@@ -2599,9 +2610,14 @@ static tree
find_or_generate_expression (basic_block block, pre_expr expr, tree stmts,
tree domstmt)
{
- pre_expr leader = bitmap_find_leader (AVAIL_OUT (block),
- get_expr_value_id (expr), domstmt);
+ pre_expr leader;
tree genop = NULL;
+
+ if (expr->kind == CONSTANT)
+ return PRE_EXPR_CONSTANT (expr);
+
+ leader = bitmap_find_leader (AVAIL_OUT (block),
+ get_expr_value_id (expr), domstmt);
if (leader)
{
if (leader->kind == NAME)
@@ -2705,14 +2721,10 @@ create_expression_by_pieces (basic_block block, pre_expr expr, tree stmts,
stmts, domstmt);
if (!genop1 || !genop2)
return NULL_TREE;
+
genop1 = fold_convert (TREE_TYPE (nary->op[0]),
genop1);
- /* Ensure op2 is a sizetype for POINTER_PLUS_EXPR. It
- may be a constant with the wrong type. */
- if (nary->opcode == POINTER_PLUS_EXPR)
- genop2 = fold_convert (sizetype, genop2);
- else
- genop2 = fold_convert (TREE_TYPE (nary->op[1]), genop2);
+ genop2 = fold_convert (TREE_TYPE (nary->op[1]), genop2);
folded = fold_build2 (nary->opcode, nary->type,
genop1, genop2);
@@ -3141,9 +3153,16 @@ do_regular_insertion (basic_block block, basic_block dom)
}
eprime = fully_constant_expression (eprime);
- vprime = get_expr_value_id (eprime);
- edoubleprime = bitmap_find_leader (AVAIL_OUT (bprime),
- vprime, NULL_TREE);
+ if (eprime->kind == CONSTANT)
+ {
+ edoubleprime = eprime;
+ }
+ else
+ {
+ vprime = get_expr_value_id (eprime);
+ edoubleprime = bitmap_find_leader (AVAIL_OUT (bprime),
+ vprime, NULL_TREE);
+ }
if (edoubleprime == NULL)
{
avail[bprime->index] = eprime;
@@ -3275,9 +3294,17 @@ do_partial_partial_insertion (basic_block block, basic_block dom)
}
eprime = fully_constant_expression (eprime);
- vprime = get_expr_value_id (eprime);
- edoubleprime = bitmap_find_leader (AVAIL_OUT (bprime),
- vprime, NULL_TREE);
+ if (eprime->kind == CONSTANT)
+ {
+ edoubleprime = eprime;
+ }
+ else
+ {
+ vprime = get_expr_value_id (eprime);
+ edoubleprime = bitmap_find_leader (AVAIL_OUT (bprime),
+ vprime, NULL_TREE);
+ }
+
if (edoubleprime == NULL)
{
by_all = false;
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index f131865..69945a5 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -2582,6 +2582,8 @@ expressions_equal_p (tree e1, tree e2)
te1 = TREE_TYPE (e1);
te2 = TREE_TYPE (e2);
+ if (te1 != te2)
+ return false;
if (TREE_CODE (e1) == TREE_LIST && TREE_CODE (e2) == TREE_LIST)
{