From 802d9f2fb5b40a5e6496e84cfc5ff75dc57059d0 Mon Sep 17 00:00:00 2001 From: rguenth Date: Mon, 3 Mar 2008 11:57:15 +0000 Subject: [PATCH] 2008-03-03 Richard Guenther * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@132836 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 12 ++++++++++++ gcc/fold-const.c | 27 +++++++++++++++++++++------ gcc/tree-ssa-loop-ivopts.c | 4 ++-- gcc/tree-ssa-sccvn.c | 12 +++++++++--- 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 + + * 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 * 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. */ -- 2.7.4