OSDN Git Service

* gcc.dg/vect/O3-vect-pr34223.c: Check vect_int_mult.
[pf3gnuchains/gcc-fork.git] / gcc / tree-ssa-sccvn.c
index 26a65f1..290b308 100644 (file)
@@ -612,21 +612,22 @@ copy_reference_ops_from_ref (tree ref, VEC(vn_reference_op_s, heap) **result)
             a matching type is not necessary and a mismatching type
             is always a spurious difference.  */
          temp.type = NULL_TREE;
-#if FIXME
          /* If this is a reference to a union member, record the union
             member size as operand.  Do so only if we are doing
             expression insertion (during FRE), as PRE currently gets
             confused with this.  */
          if (may_insert
+             && TREE_OPERAND (ref, 2) == NULL_TREE
              && TREE_CODE (DECL_CONTEXT (TREE_OPERAND (ref, 1))) == UNION_TYPE
              && integer_zerop (DECL_FIELD_OFFSET (TREE_OPERAND (ref, 1)))
              && integer_zerop (DECL_FIELD_BIT_OFFSET (TREE_OPERAND (ref, 1))))
            temp.op0 = TYPE_SIZE (TREE_TYPE (TREE_OPERAND (ref, 1)));
          else
-#endif
-           /* Record field as operand.  */
-           temp.op0 = TREE_OPERAND (ref, 1);
-           temp.op1 = TREE_OPERAND (ref, 2);     
+           {
+             /* Record field as operand.  */
+             temp.op0 = TREE_OPERAND (ref, 1);
+             temp.op1 = TREE_OPERAND (ref, 2);
+           }
          break;
        case ARRAY_RANGE_REF:
        case ARRAY_REF:
@@ -1402,9 +1403,17 @@ vn_phi_compute_hash (vn_phi_t vp1)
   hashval_t result = 0;
   int i;
   tree phi1op;
+  tree type;
 
   result = vp1->block->index;
 
+  /* If all PHI arguments are constants we need to distinguish
+     the PHI node via its type.  */
+  type = TREE_TYPE (VEC_index (tree, vp1->phiargs, 0));
+  result += (INTEGRAL_TYPE_P (type)
+            + (INTEGRAL_TYPE_P (type)
+               ? TYPE_PRECISION (type) + TYPE_UNSIGNED (type) : 0));
+
   for (i = 0; VEC_iterate (tree, vp1->phiargs, i, phi1op); i++)
     {
       if (phi1op == VN_TOP)
@@ -1437,6 +1446,12 @@ vn_phi_eq (const void *p1, const void *p2)
       int i;
       tree phi1op;
 
+      /* If the PHI nodes do not have compatible types
+        they are not the same.  */
+      if (!types_compatible_p (TREE_TYPE (VEC_index (tree, vp1->phiargs, 0)),
+                              TREE_TYPE (VEC_index (tree, vp2->phiargs, 0))))
+       return false;
+
       /* Any phi in the same block will have it's arguments in the
         same edge order, because of how we store phi nodes.  */
       for (i = 0; VEC_iterate (tree, vp1->phiargs, i, phi1op); i++)
@@ -1458,7 +1473,7 @@ static VEC(tree, heap) *shared_lookup_phiargs;
    value number if it exists in the hash table.  Return NULL_TREE if
    it does not exist in the hash table. */
 
-static tree
+tree
 vn_phi_lookup (gimple phi)
 {
   void **slot;
@@ -1598,7 +1613,7 @@ defs_to_varying (gimple stmt)
 }
 
 static bool expr_has_constants (tree expr);
-static tree try_to_simplify (gimple stmt);
+static tree valueize_expr (tree expr);
 
 /* Visit a copy between LHS and RHS, return true if the value number
    changed.  */
@@ -1607,13 +1622,17 @@ static bool
 visit_copy (tree lhs, tree rhs)
 {
   /* Follow chains of copies to their destination.  */
-  while (SSA_VAL (rhs) != rhs && TREE_CODE (SSA_VAL (rhs)) == SSA_NAME)
+  while (TREE_CODE (rhs) == SSA_NAME
+        && SSA_VAL (rhs) != rhs)
     rhs = SSA_VAL (rhs);
 
   /* The copy may have a more interesting constant filled expression
      (we don't, since we know our RHS is just an SSA name).  */
-  VN_INFO (lhs)->has_constants = VN_INFO (rhs)->has_constants;
-  VN_INFO (lhs)->expr = VN_INFO (rhs)->expr;
+  if (TREE_CODE (rhs) == SSA_NAME)
+    {
+      VN_INFO (lhs)->has_constants = VN_INFO (rhs)->has_constants;
+      VN_INFO (lhs)->expr = VN_INFO (rhs)->expr;
+    }
 
   return set_ssa_val_to (lhs, rhs);
 }
@@ -1724,12 +1743,14 @@ visit_reference_op_load (tree lhs, tree op, gimple stmt)
         So first simplify and lookup this expression to see if it
         is already available.  */
       tree val = fold_build1 (VIEW_CONVERT_EXPR, TREE_TYPE (op), result);
-      if (stmt
-         && !is_gimple_min_invariant (val)
-         && TREE_CODE (val) != SSA_NAME)
+      if ((CONVERT_EXPR_P (val)
+          || TREE_CODE (val) == VIEW_CONVERT_EXPR)
+         && TREE_CODE (TREE_OPERAND (val, 0)) == SSA_NAME)
         {
-         tree tem = try_to_simplify (stmt);
-         if (tem)
+         tree tem = valueize_expr (vn_get_expr_for (TREE_OPERAND (val, 0)));
+         if ((CONVERT_EXPR_P (tem)
+              || TREE_CODE (tem) == VIEW_CONVERT_EXPR)
+             && (tem = fold_unary (TREE_CODE (val), TREE_TYPE (val), tem)))
            val = tem;
        }
       result = val;