diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3625d9be2482e7b844b2a7c5c5b97f260af471df..0e30db8f7e76d8f2aab9b48c4fbc999edfac1849 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,7 @@
+2011-05-17  Richard Guenther  <rguenther@suse.de>
+
+	* gimple.c (type_hash_pair_compare): Fix comparison.
+
 2011-05-17  Richard Guenther  <rguenther@suse.de>
 
 	* gimple.c (iterative_hash_gimple_type): Simplify singleton
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 0c07ac24989a9e44463fc2e1ebb3664d145c50af..831ca31e0e51135b3dc0b706a89e19c44861acba 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -4070,9 +4070,11 @@ type_hash_pair_compare (const void *p1_, const void *p2_)
 {
   const struct type_hash_pair *p1 = (const struct type_hash_pair *) p1_;
   const struct type_hash_pair *p2 = (const struct type_hash_pair *) p2_;
-  if (p1->hash == p2->hash)
-    return TYPE_UID (p1->type) - TYPE_UID (p2->type);
-  return p1->hash - p2->hash;
+  if (p1->hash < p2->hash)
+    return -1;
+  else if (p1->hash > p2->hash)
+    return 1;
+  return 0;
 }
 
 /* Returning a hash value for gimple type TYPE combined with VAL.