tree-ssa-sccvn.c (visit_reference_op_store): Do not insert struct copies into the...
authorRichard Guenther <rguenther@suse.de>
Mon, 3 Mar 2008 11:57:15 +0000 (11:57 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 3 Mar 2008 11:57:15 +0000 (11:57 +0000)
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

gcc/ChangeLog
gcc/fold-const.c
gcc/tree-ssa-loop-ivopts.c
gcc/tree-ssa-sccvn.c

index 6565763..d35d6ed 100644 (file)
@@ -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
index 5af6f0d..6a70e17 100644 (file)
@@ -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:
index 4121d82..02fe707 100644 (file)
@@ -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 ... */
index 929354e..ce4a401 100644 (file)
@@ -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. */