aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2008-03-03 11:57:15 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2008-03-03 11:57:15 +0000
commit9a3277660593535784174ac188b09a151ca9aaee (patch)
treece54fd8c85046ba566eb8d22fa71e375248c6f70 /gcc
parent6a732743bdccfe0eac5e67d90ef5ee5fe70dfe35 (diff)
downloadgcc-9a3277660593535784174ac188b09a151ca9aaee.zip
gcc-9a3277660593535784174ac188b09a151ca9aaee.tar.gz
gcc-9a3277660593535784174ac188b09a151ca9aaee.tar.bz2
tree-ssa-sccvn.c (visit_reference_op_store): Do not insert struct copies into the expression table.
2008-03-03 Richard Guenther <rguenther@suse.de> * tree-ssa-sccvn.c (visit_reference_op_store): Do not insert struct copies into the expression table. (simplify_unary_expression): Handle VIEW_CONVERT_EXPR. (try_to_simplify): Likewise. * fold-const.c (fold_unary): Fold VIEW_CONVERT_EXPR of integral and pointer arguments which do not change the precision to NOP_EXPRs. * tree-ssa-loop-ivopts.c (may_be_nonaddressable_p): Adjust VIEW_CONVERT_EXPR case. From-SVN: r132836
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog12
-rw-r--r--gcc/fold-const.c27
-rw-r--r--gcc/tree-ssa-loop-ivopts.c4
-rw-r--r--gcc/tree-ssa-sccvn.c12
4 files changed, 44 insertions, 11 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6565763..d35d6ed 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,15 @@
+2008-03-03 Richard Guenther <rguenther@suse.de>
+
+ * tree-ssa-sccvn.c (visit_reference_op_store): Do not insert
+ struct copies into the expression table.
+ (simplify_unary_expression): Handle VIEW_CONVERT_EXPR.
+ (try_to_simplify): Likewise.
+ * fold-const.c (fold_unary): Fold VIEW_CONVERT_EXPR of
+ integral and pointer arguments which do not change the
+ precision to NOP_EXPRs.
+ * tree-ssa-loop-ivopts.c (may_be_nonaddressable_p): Adjust
+ VIEW_CONVERT_EXPR case.
+
2008-03-02 Sebastian Pop <sebastian.pop@amd.com>
* tree-scalar-evolution.c (instantiate_parameters_1): An SSA_NAME
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 5af6f0d..6a70e17 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -8277,13 +8277,28 @@ fold_unary (enum tree_code code, tree type, tree op0)
case VIEW_CONVERT_EXPR:
if (TREE_TYPE (op0) == type)
return op0;
- if (TREE_CODE (op0) == VIEW_CONVERT_EXPR
- || (TREE_CODE (op0) == NOP_EXPR
- && INTEGRAL_TYPE_P (TREE_TYPE (op0))
- && INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (op0, 0)))
- && TYPE_PRECISION (TREE_TYPE (op0))
- == TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op0, 0)))))
+ if (TREE_CODE (op0) == VIEW_CONVERT_EXPR)
return fold_build1 (VIEW_CONVERT_EXPR, type, TREE_OPERAND (op0, 0));
+
+ /* For integral conversions with the same precision or pointer
+ conversions use a NOP_EXPR instead. */
+ if ((INTEGRAL_TYPE_P (type) && INTEGRAL_TYPE_P (TREE_TYPE (op0))
+ && TYPE_PRECISION (type) == TYPE_PRECISION (TREE_TYPE (op0))
+ /* Do not muck with VIEW_CONVERT_EXPRs that convert from
+ a sub-type to its base type as generated by the Ada FE. */
+ && !TREE_TYPE (TREE_TYPE (op0)))
+ || (POINTER_TYPE_P (type) && POINTER_TYPE_P (TREE_TYPE (op0))))
+ return fold_convert (type, op0);
+
+ /* Strip inner integral conversions that do not change the precision. */
+ if ((TREE_CODE (op0) == NOP_EXPR
+ || TREE_CODE (op0) == CONVERT_EXPR)
+ && INTEGRAL_TYPE_P (TREE_TYPE (op0))
+ && INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (op0, 0)))
+ && (TYPE_PRECISION (TREE_TYPE (op0))
+ == TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op0, 0)))))
+ return fold_build1 (VIEW_CONVERT_EXPR, type, TREE_OPERAND (op0, 0));
+
return fold_view_convert_expr (type, op0);
case NEGATE_EXPR:
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index 4121d82..02fe707f 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -1525,8 +1525,8 @@ may_be_nonaddressable_p (tree expr)
and make them look addressable. After some processing the
non-addressability may be uncovered again, causing ADDR_EXPRs
of inappropriate objects to be built. */
- if (AGGREGATE_TYPE_P (TREE_TYPE (expr))
- && !AGGREGATE_TYPE_P (TREE_TYPE (TREE_OPERAND (expr, 0))))
+ if (is_gimple_reg (TREE_OPERAND (expr, 0))
+ || is_gimple_min_invariant (TREE_OPERAND (expr, 0)))
return true;
/* ... fall through ... */
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 929354e..ce4a401 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -1259,7 +1259,10 @@ visit_reference_op_store (tree lhs, tree op, tree stmt)
changed |= set_ssa_val_to (vdef, vdef);
}
- vn_reference_insert (lhs, op, vdefs);
+ /* Do not insert structure copies into the tables. */
+ if (is_gimple_min_invariant (op)
+ || is_gimple_reg (op))
+ vn_reference_insert (lhs, op, vdefs);
}
else
{
@@ -1497,13 +1500,15 @@ simplify_unary_expression (tree rhs)
else if (TREE_CODE (rhs) == NOP_EXPR
|| TREE_CODE (rhs) == CONVERT_EXPR
|| TREE_CODE (rhs) == REALPART_EXPR
- || TREE_CODE (rhs) == IMAGPART_EXPR)
+ || TREE_CODE (rhs) == IMAGPART_EXPR
+ || TREE_CODE (rhs) == VIEW_CONVERT_EXPR)
{
/* We want to do tree-combining on conversion-like expressions.
Make sure we feed only SSA_NAMEs or constants to fold though. */
tree tem = valueize_expr (VN_INFO (op0)->expr);
if (UNARY_CLASS_P (tem)
|| BINARY_CLASS_P (tem)
+ || TREE_CODE (tem) == VIEW_CONVERT_EXPR
|| TREE_CODE (tem) == SSA_NAME
|| is_gimple_min_invariant (tem))
op0 = tem;
@@ -1555,7 +1560,8 @@ try_to_simplify (tree stmt, tree rhs)
/* Fallthrough for some codes that can operate on registers. */
if (!(TREE_CODE (rhs) == REALPART_EXPR
- || TREE_CODE (rhs) == IMAGPART_EXPR))
+ || TREE_CODE (rhs) == IMAGPART_EXPR
+ || TREE_CODE (rhs) == VIEW_CONVERT_EXPR))
break;
/* We could do a little more with unary ops, if they expand
into binary ops, but it's debatable whether it is worth it. */