OSDN Git Service

PR c++/51662
[pf3gnuchains/gcc-fork.git] / gcc / tree-ssa-sccvn.c
index 9222cb5..6ed076d 100644 (file)
@@ -546,6 +546,7 @@ vn_reference_eq (const void *p1, const void *p2)
          tem1.type = TREE_TYPE (tem1.op0);
          tem1.opcode = TREE_CODE (tem1.op0);
          vro1 = &tem1;
+         deref1 = false;
        }
       if (deref2 && vro2->opcode == ADDR_EXPR)
        {
@@ -554,7 +555,10 @@ vn_reference_eq (const void *p1, const void *p2)
          tem2.type = TREE_TYPE (tem2.op0);
          tem2.opcode = TREE_CODE (tem2.op0);
          vro2 = &tem2;
+         deref2 = false;
        }
+      if (deref1 != deref2)
+       return false;
       if (!vn_reference_op_eq (vro1, vro2))
        return false;
       ++j;
@@ -2103,12 +2107,26 @@ print_scc (FILE *out, VEC (tree, heap) *scc)
 static inline bool
 set_ssa_val_to (tree from, tree to)
 {
-  tree currval;
+  tree currval = SSA_VAL (from);
 
-  if (from != to
-      && TREE_CODE (to) == SSA_NAME
-      && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (to))
-    to = from;
+  if (from != to)
+    {
+      if (currval == from)
+       {
+         if (dump_file && (dump_flags & TDF_DETAILS))
+           {
+             fprintf (dump_file, "Not changing value number of ");
+             print_generic_expr (dump_file, from, 0);
+             fprintf (dump_file, " from VARYING to ");
+             print_generic_expr (dump_file, to, 0);
+             fprintf (dump_file, "\n");
+           }
+         return false;
+       }
+      else if (TREE_CODE (to) == SSA_NAME
+              && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (to))
+       to = from;
+    }
 
   /* The only thing we allow as value numbers are VN_TOP, ssa_names
      and invariants.  So assert that here.  */
@@ -2125,8 +2143,6 @@ set_ssa_val_to (tree from, tree to)
       print_generic_expr (dump_file, to, 0);
     }
 
-  currval = SSA_VAL (from);
-
   if (currval != to  && !operand_equal_p (currval, to, OEP_PURE_SAME))
     {
       VN_INFO (from)->valnum = to;
@@ -3124,6 +3140,8 @@ process_scc (VEC (tree, heap) *scc)
     {
       changed = false;
       iterations++;
+      if (dump_file && (dump_flags & TDF_DETAILS))
+       fprintf (dump_file, "Starting iteration %d\n", iterations);
       /* As we are value-numbering optimistically we have to
         clear the expression tables and the simplified expressions
         in each iteration until we converge.  */