OSDN Git Service

PR tree-optimization/36830
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 27 Jul 2008 16:55:31 +0000 (16:55 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 27 Jul 2008 16:55:31 +0000 (16:55 +0000)
* tree-ssa-sccvn.c (vn_reference_op_compute_hash): Hash operand #2.
(expressions_equal_p): Return false if only one operand is null.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@138191 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/tree-ssa-sccvn.c

index 116c3c1..c69e60e 100644 (file)
@@ -1,3 +1,9 @@
+2008-07-27  Eric Botcazou  <ebotcazou@adacore.com>
+
+       PR tree-optimization/36830
+       * tree-ssa-sccvn.c (vn_reference_op_compute_hash): Hash operand #2.
+       (expressions_equal_p): Return false if only one operand is null.
+
 2008-07-26  Gerald Pfeifer  <gerald@pfeifer.com>
 
        * doc/install.texi (powerpc-*-netbsd*): Remove redundant texinfo
index 48b5297..85ceb7e 100644 (file)
@@ -319,7 +319,8 @@ static hashval_t
 vn_reference_op_compute_hash (const vn_reference_op_t vro1)
 {
   return iterative_hash_expr (vro1->op0, vro1->opcode)
-    + iterative_hash_expr (vro1->op1, vro1->opcode);
+    + iterative_hash_expr (vro1->op1, vro1->opcode)
+    + iterative_hash_expr (vro1->op2, vro1->opcode);
 }
 
 /* Return the hashcode for a given reference operation P1.  */
@@ -2587,22 +2588,24 @@ get_next_value_id (void)
 }
 
 
-/* Compare two expressions E1 and E2 and return true if they are
-   equal.  */
+/* Compare two expressions E1 and E2 and return true if they are equal.  */
 
 bool
 expressions_equal_p (tree e1, tree e2)
 {
-  tree te1, te2;
-
+  /* The obvious case.  */
   if (e1 == e2)
     return true;
 
-  te1 = TREE_TYPE (e1);
-  te2 = TREE_TYPE (e2);
-  if (te1 != te2)
+  /* If only one of them is null, they cannot be equal.  */
+  if (!e1 || !e2)
+    return false;
+
+  /* Likewise if they are not of the same type.  */
+  if (TREE_TYPE (e1) != TREE_TYPE (e2))
     return false;
 
+  /* Recurse on elements of lists.  */
   if (TREE_CODE (e1) == TREE_LIST && TREE_CODE (e2) == TREE_LIST)
     {
       tree lop1 = e1;
@@ -2617,10 +2620,11 @@ expressions_equal_p (tree e1, tree e2)
            return false;
        }
       return true;
-
     }
-  else if (TREE_CODE (e1) == TREE_CODE (e2)
-          && operand_equal_p (e1, e2, OEP_PURE_SAME))
+
+  /* Now perform the actual comparison.  */
+  if (TREE_CODE (e1) == TREE_CODE (e2)
+      && operand_equal_p (e1, e2, OEP_PURE_SAME))
     return true;
 
   return false;