for gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	PR debug/45673
	PR debug/45604
	PR debug/45419
	PR debug/45408
	* fold-const.c (operand_equal_p): Compare both pointer types
	of MEM_REFs.
	* tree.c (iterative_hash_expr): Hash both of them too.

Index: gcc/fold-const.c
===================================================================
--- gcc/fold-const.c.orig	2010-09-21 05:42:27.671516671 -0300
+++ gcc/fold-const.c	2010-09-21 05:45:03.200676171 -0300
@@ -2600,6 +2600,8 @@ operand_equal_p (const_tree arg0, const_
 		       && TYPE_SIZE (TREE_TYPE (arg1))
 		       && operand_equal_p (TYPE_SIZE (TREE_TYPE (arg0)),
 					   TYPE_SIZE (TREE_TYPE (arg1)), flags)))
+		  && (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (arg0, 0)))
+		      == TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (arg1, 0))))
 		  && (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (arg0, 1)))
 		      == TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (arg1, 1))))
 		  && OP_SAME (0) && OP_SAME (1));
Index: gcc/tree.c
===================================================================
--- gcc/tree.c.orig	2010-09-21 05:42:27.137424998 -0300
+++ gcc/tree.c	2010-09-21 05:44:20.498430669 -0300
@@ -6791,20 +6791,21 @@ iterative_hash_expr (const_tree t, hashv
 	return val;
       }
     case MEM_REF:
-      {
-	/* The type of the second operand is relevant, except for
-	   its top-level qualifiers.  */
-	tree type = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (t, 1)));
-
-	val = iterative_hash_object (TYPE_HASH (type), val);
-
-	/* We could use the standard hash computation from this point
-	   on.  */
-	val = iterative_hash_object (code, val);
-	val = iterative_hash_expr (TREE_OPERAND (t, 1), val);
-	val = iterative_hash_expr (TREE_OPERAND (t, 0), val);
-	return val;
-      }
+      for (i = 0; i <= 1; i++)
+	{
+	  /* The types of the operands are relevant, except for their
+	     top-level qualifiers.  */
+	  tree type = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (t, i)));
+
+	  val = iterative_hash_object (TYPE_HASH (type), val);
+	}
+
+      /* We could use the standard hash computation from this point
+	 on.  */
+      val = iterative_hash_object (code, val);
+      val = iterative_hash_expr (TREE_OPERAND (t, 1), val);
+      val = iterative_hash_expr (TREE_OPERAND (t, 0), val);
+      return val;
     case FUNCTION_DECL:
       /* When referring to a built-in FUNCTION_DECL, use the __builtin__ form.
 	 Otherwise nodes that compare equal according to operand_equal_p might
