From c3baaad9da1fdaa95ff5b8a69fc7925ede13d8c9 Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Fri, 6 Jan 2017 13:30:08 +0100
Subject: [PATCH 2/2] IPA ICF: make algorithm stable to survive -fcompare-debug

gcc/testsuite/ChangeLog:

2017-01-06  Martin Liska  <mliska@suse.cz>

	* gcc.dg/ipa/ipa-icf-1.c: Change scanned pattern.
	* gcc.dg/ipa/ipa-icf-10.c: Likewise.
	* gcc.dg/ipa/ipa-icf-11.c: Likewise.
	* gcc.dg/ipa/ipa-icf-12.c: Likewise.
	* gcc.dg/ipa/ipa-icf-13.c: Likewise.
	* gcc.dg/ipa/ipa-icf-16.c: Likewise.
	* gcc.dg/ipa/ipa-icf-18.c: Likewise.
	* gcc.dg/ipa/ipa-icf-2.c: Likewise.
	* gcc.dg/ipa/ipa-icf-20.c: Likewise.
	* gcc.dg/ipa/ipa-icf-21.c: Likewise.
	* gcc.dg/ipa/ipa-icf-23.c: Likewise.
	* gcc.dg/ipa/ipa-icf-25.c: Likewise.
	* gcc.dg/ipa/ipa-icf-26.c: Likewise.
	* gcc.dg/ipa/ipa-icf-27.c: Likewise.
	* gcc.dg/ipa/ipa-icf-3.c: Likewise.
	* gcc.dg/ipa/ipa-icf-35.c: Likewise.
	* gcc.dg/ipa/ipa-icf-36.c: Likewise.
	* gcc.dg/ipa/ipa-icf-37.c: Likewise.
	* gcc.dg/ipa/ipa-icf-5.c: Likewise.
	* gcc.dg/ipa/ipa-icf-7.c: Likewise.
	* gcc.dg/ipa/ipa-icf-8.c: Likewise.
	* gcc.dg/ipa/pr64307.c: Likewise.
	* gcc.dg/ipa/pr77653.c: Likewise.

gcc/ChangeLog:

2017-01-06  Martin Liska  <mliska@suse.cz>

	* ipa-icf.c (sort_sem_items_by_decl_uid): New function.
	(sort_congruence_classes_by_decl_uid): Likewise.
	(sort_congruence_class_groups_by_decl_uid): Likewise.
	(sem_item_optimizer::merge_classes): Sort class, groups in these
	classes and members in the groups by DECL_UID of declarations.
	This would make merge operations stable.
---
 gcc/ipa-icf.c                         | 92 +++++++++++++++++++++++++++++++++--
 gcc/testsuite/gcc.dg/ipa/ipa-icf-1.c  |  2 +-
 gcc/testsuite/gcc.dg/ipa/ipa-icf-10.c |  2 +-
 gcc/testsuite/gcc.dg/ipa/ipa-icf-11.c |  2 +-
 gcc/testsuite/gcc.dg/ipa/ipa-icf-12.c |  2 +-
 gcc/testsuite/gcc.dg/ipa/ipa-icf-13.c |  6 +--
 gcc/testsuite/gcc.dg/ipa/ipa-icf-16.c |  2 +-
 gcc/testsuite/gcc.dg/ipa/ipa-icf-18.c |  2 +-
 gcc/testsuite/gcc.dg/ipa/ipa-icf-2.c  |  2 +-
 gcc/testsuite/gcc.dg/ipa/ipa-icf-20.c |  2 +-
 gcc/testsuite/gcc.dg/ipa/ipa-icf-21.c |  2 +-
 gcc/testsuite/gcc.dg/ipa/ipa-icf-23.c |  2 +-
 gcc/testsuite/gcc.dg/ipa/ipa-icf-25.c |  4 +-
 gcc/testsuite/gcc.dg/ipa/ipa-icf-26.c |  2 +-
 gcc/testsuite/gcc.dg/ipa/ipa-icf-27.c |  2 +-
 gcc/testsuite/gcc.dg/ipa/ipa-icf-3.c  |  2 +-
 gcc/testsuite/gcc.dg/ipa/ipa-icf-35.c |  6 +--
 gcc/testsuite/gcc.dg/ipa/ipa-icf-36.c | 10 ++--
 gcc/testsuite/gcc.dg/ipa/ipa-icf-37.c | 10 ++--
 gcc/testsuite/gcc.dg/ipa/ipa-icf-5.c  |  2 +-
 gcc/testsuite/gcc.dg/ipa/ipa-icf-7.c  |  2 +-
 gcc/testsuite/gcc.dg/ipa/ipa-icf-8.c  |  2 +-
 gcc/testsuite/gcc.dg/ipa/pr64307.c    |  2 +-
 gcc/testsuite/gcc.dg/ipa/pr77653.c    |  2 +-
 24 files changed, 124 insertions(+), 40 deletions(-)

diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
index 28de251c421..4c835c39e3d 100644
--- a/gcc/ipa-icf.c
+++ b/gcc/ipa-icf.c
@@ -3380,6 +3380,66 @@ sem_item_optimizer::dump_cong_classes (void)
   free (histogram);
 }
 
+/* Sort pair of sem_items A and B by DECL_UID.  */
+
+static int
+sort_sem_items_by_decl_uid (const void *a, const void *b)
+{
+  const sem_item *i1 = *(const sem_item * const *)a;
+  const sem_item *i2 = *(const sem_item * const *)b;
+
+  int uid1 = DECL_UID (i1->decl);
+  int uid2 = DECL_UID (i2->decl);
+
+  if (uid1 < uid2)
+    return -1;
+  else if (uid1 > uid2)
+    return 1;
+  else
+    return 0;
+}
+
+/* Sort pair of congruence_classes A and B by DECL_UID of the first member.  */
+
+static int
+sort_congruence_classes_by_decl_uid (const void *a, const void *b)
+{
+  const congruence_class *c1 = *(const congruence_class * const *)a;
+  const congruence_class *c2 = *(const congruence_class * const *)b;
+
+  int uid1 = DECL_UID (c1->members[0]->decl);
+  int uid2 = DECL_UID (c2->members[0]->decl);
+
+  if (uid1 < uid2)
+    return -1;
+  else if (uid1 > uid2)
+    return 1;
+  else
+    return 0;
+}
+
+/* Sort pair of congruence_class_groups A and B by
+   DECL_UID of the first member of a first group.  */
+
+static int
+sort_congruence_class_groups_by_decl_uid (const void *a, const void *b)
+{
+  const congruence_class_group *g1
+    = *(const congruence_class_group * const *)a;
+  const congruence_class_group *g2
+    = *(const congruence_class_group * const *)b;
+
+  int uid1 = DECL_UID (g1->classes[0]->members[0]->decl);
+  int uid2 = DECL_UID (g2->classes[0]->members[0]->decl);
+
+  if (uid1 < uid2)
+    return -1;
+  else if (uid1 > uid2)
+    return 1;
+  else
+    return 0;
+}
+
 /* After reduction is done, we can declare all items in a group
    to be equal. PREV_CLASS_COUNT is start number of classes
    before reduction. True is returned if there's a merge operation
@@ -3397,6 +3457,22 @@ sem_item_optimizer::merge_classes (unsigned int prev_class_count)
 
   bool merged_p = false;
 
+  /* PR lto/78211
+     Sort functions in congruence classes by DECL_UID and do the same
+     for the classes to not to break -fcompare-debug.  */
+
+  for (hash_table<congruence_class_hash>::iterator it = m_classes.begin ();
+       it != m_classes.end (); ++it)
+    {
+      for (unsigned int i = 0; i < (*it)->classes.length (); i++)
+	{
+	  congruence_class *c = (*it)->classes[i];
+	  c->members.qsort (sort_sem_items_by_decl_uid);
+	}
+
+      (*it)->classes.qsort (sort_congruence_classes_by_decl_uid);
+    }
+
   for (hash_table<congruence_class_hash>::iterator it = m_classes.begin ();
        it != m_classes.end (); ++it)
     for (unsigned int i = 0; i < (*it)->classes.length (); i++)
@@ -3409,6 +3485,13 @@ sem_item_optimizer::merge_classes (unsigned int prev_class_count)
 	  }
       }
 
+  auto_vec <congruence_class_group *> classes;
+  for (hash_table<congruence_class_hash>::iterator it = m_classes.begin ();
+       it != m_classes.end (); ++it)
+    classes.safe_push (*it);
+
+  classes.qsort (sort_congruence_class_groups_by_decl_uid);
+
   if (dump_file)
     {
       fprintf (dump_file, "\nItem count: %u\n", item_count);
@@ -3426,11 +3509,12 @@ sem_item_optimizer::merge_classes (unsigned int prev_class_count)
 	       item_count ? 100.0f * equal_items / item_count : 0.0f);
     }
 
-  for (hash_table<congruence_class_hash>::iterator it = m_classes.begin ();
-       it != m_classes.end (); ++it)
-    for (unsigned int i = 0; i < (*it)->classes.length (); i++)
+  unsigned int l;
+  congruence_class_group *it;
+  FOR_EACH_VEC_ELT (classes, l, it)
+    for (unsigned int i = 0; i < it->classes.length (); i++)
       {
-	congruence_class *c = (*it)->classes[i];
+	congruence_class *c = it->classes[i];
 
 	if (c->members.length () == 1)
 	  continue;
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-1.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-1.c
index af86b9b8d50..a3d88585a9e 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-icf-1.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-1.c
@@ -56,5 +56,5 @@ int main(int argc, char **argv)
   return 0;
 }
 
-/* { dg-final { scan-ipa-dump "Semantic equality hit:x2->x1" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:x1->x2" "icf"  } } */
 /* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf"  } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-10.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-10.c
index 6a2dd008849..5f76c1d87e7 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-icf-10.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-10.c
@@ -29,5 +29,5 @@ int main(int argc, char **argv)
   return 0;
 }
 
-/* { dg-final { scan-ipa-dump "Semantic equality hit:funkce->ferda" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:ferda->funkce" "icf"  } } */
 /* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf"  } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-11.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-11.c
index 33b62ca6eb7..2610af9e55c 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-icf-11.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-11.c
@@ -24,5 +24,5 @@ int main(int argc, char **argv)
   return f0(argc) * f1(argc);
 }
 
-/* { dg-final { scan-ipa-dump "Semantic equality hit:f1->f0" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:f0->f1" "icf"  } } */
 /* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf"  } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-12.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-12.c
index 8c03a47431b..8e4aa56b032 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-icf-12.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-12.c
@@ -73,5 +73,5 @@ int main(int argc, char **argv)
   return 0;
 }
 
-/* { dg-final { scan-ipa-dump "Semantic equality hit:nsd->gcd" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:gcd->nsd" "icf"  } } */
 /* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf"  } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-13.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-13.c
index dd3f262146f..09d817c4030 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-icf-13.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-13.c
@@ -187,7 +187,7 @@ int main(int argc, char **argv)
   printf("Test2: %d, %d, gdc: %d\n", a, b, nsd(a, b));
 }
 
-/* { dg-final { scan-ipa-dump "Semantic equality hit:s2->s1" "icf"  } } */
-/* { dg-final { scan-ipa-dump "Semantic equality hit:nsd_different_result2->nsd_different_result" "icf"  } } */
-/* { dg-final { scan-ipa-dump "Semantic equality hit:nsd->gcd" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:s1->s2" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:nsd_different_result->nsd_different_result2" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:gcd->nsd" "icf"  } } */
 /* { dg-final { scan-ipa-dump "Equal symbols: 3" "icf"  } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-16.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-16.c
index 6f038f13cf9..a2613af5dd5 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-icf-16.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-16.c
@@ -22,5 +22,5 @@ int main()
   return foo() + bar();
 }
 
-/* { dg-final { scan-ipa-dump "Semantic equality hit:bar->foo" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:foo->bar" "icf"  } } */
 /* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf"  } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-18.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-18.c
index a8e28c1ff3a..e246c2b3404 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-icf-18.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-18.c
@@ -32,5 +32,5 @@ int main()
   return 0;
 }
 
-/* { dg-final { scan-ipa-dump "Semantic equality hit:bar->foo" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:foo->bar" "icf"  } } */
 /* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf"  } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-2.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-2.c
index 4d3cbafff4a..983e3d818d0 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-icf-2.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-2.c
@@ -64,5 +64,5 @@ int main(int argc, char **argv)
   return 0;
 }
 
-/* { dg-final { scan-ipa-dump "Semantic equality hit:f2->f1" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:f1->f2" "icf"  } } */
 /* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf"  } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-20.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-20.c
index 470e466ba23..46dc70492f0 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-icf-20.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-20.c
@@ -23,5 +23,5 @@ int main()
   return 0;
 }
 
-/* { dg-final { scan-ipa-dump "Semantic equality hit:bar->foo" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:foo->bar" "icf"  } } */
 /* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf"  } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-21.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-21.c
index 447fd7bad51..a20b4a43ffe 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-icf-21.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-21.c
@@ -22,5 +22,5 @@ int main()
   return 2;
 }
 
-/* { dg-final { scan-ipa-dump "Semantic equality hit:bar->foo" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:foo->bar" "icf"  } } */
 /* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf"  } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-23.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-23.c
index 7787f06938e..02bb138c28d 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-icf-23.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-23.c
@@ -24,5 +24,5 @@ int main()
   return foo(0) + bar(0);
 }
 
-/* { dg-final { scan-ipa-dump "Semantic equality hit:bar->foo" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:foo->bar" "icf"  } } */
 /* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf"  } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-25.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-25.c
index 7e42052fe20..4b364eb7c72 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-icf-25.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-25.c
@@ -46,6 +46,6 @@ int main()
   return foo() + bar();
 }
 
-/* { dg-final { scan-ipa-dump "Semantic equality hit:bar->foo" "icf"  } } */
-/* { dg-final { scan-ipa-dump "Semantic equality hit:zap->zip" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:foo->bar" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:zip->zap" "icf"  } } */
 /* { dg-final { scan-ipa-dump "Equal symbols: 2" "icf"  } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-26.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-26.c
index f3bb675d82a..325ece1befa 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-icf-26.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-26.c
@@ -38,5 +38,5 @@ int main()
   return 0;
 }
 
-/* { dg-final { scan-ipa-dump "Semantic equality hit:remove->destroy" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:destroy->remove" "icf"  } } */
 /* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf"  } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-27.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-27.c
index 7265ee4035e..bc49e58cb95 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-icf-27.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-27.c
@@ -25,5 +25,5 @@ int main()
   return 0;
 }
 
-/* { dg-final { scan-ipa-dump "Semantic equality hit:remove->destroy" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:destroy->remove" "icf"  } } */
 /* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf"  } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-3.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-3.c
index 6418acea19c..2ecab2335c2 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-icf-3.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-3.c
@@ -31,5 +31,5 @@ int main()
   return 0;
 }
 
-/* { dg-final { scan-ipa-dump "Semantic equality hit:bar->foo" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:foo->bar" "icf"  } } */
 /* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf"  } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-35.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-35.c
index ace6ae2b353..d194f918fd0 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-icf-35.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-35.c
@@ -25,6 +25,6 @@ int main()
 }
 
 /* { dg-final { scan-ipa-dump "Equal symbols: 3" "icf"  } } */
-/* { dg-final { scan-ipa-dump "Semantic equality hit:f2->f1" "icf"  } } */
-/* { dg-final { scan-ipa-dump "Semantic equality hit:d->c" "icf"  } } */
-/* { dg-final { scan-ipa-dump "Semantic equality hit:b->a" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:f1->f2" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:c->d" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:a->b" "icf"  } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-36.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-36.c
index d8cd5c8567e..5d125d0e1b7 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-icf-36.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-36.c
@@ -29,8 +29,8 @@ int t(int tt)
   }
 }
 /* { dg-final { scan-ipa-dump "Equal symbols: 6" "icf"  } } */
-/* { dg-final { scan-ipa-dump "Semantic equality hit:b->a" "icf"  } } */
-/* { dg-final { scan-ipa-dump "Semantic equality hit:d->c" "icf"  } } */
-/* { dg-final { scan-ipa-dump "Semantic equality hit:f->e" "icf"  } } */
-/* { dg-final { scan-ipa-dump "Semantic equality hit:h->g" "icf"  } } */
-/* { dg-final { scan-ipa-dump "Semantic equality hit:k->i" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:a->b" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:c->d" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:e->f" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:g->h" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:i->k" "icf"  } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-37.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-37.c
index 7314697e887..5c02e8ec336 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-icf-37.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-37.c
@@ -29,8 +29,8 @@ int t(int tt)
   }
 }
 /* { dg-final { scan-ipa-dump "Equal symbols: 5" "icf"  } } */
-/* { dg-final { scan-ipa-dump "Semantic equality hit:b->a" "icf"  } } */
-/* { dg-final { scan-ipa-dump "Semantic equality hit:d->c" "icf"  } } */
-/* { dg-final { scan-ipa-dump "Semantic equality hit:f->e" "icf"  } } */
-/* { dg-final { scan-ipa-dump "Semantic equality hit:h->g" "icf"  } } */
-/* { dg-final { scan-ipa-dump "Semantic equality hit:j->i" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:a->b" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:c->d" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:e->f" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:g->h" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:i->j" "icf"  } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-5.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-5.c
index bef80f27f65..b2d48f9d79d 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-icf-5.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-5.c
@@ -51,5 +51,5 @@ int main()
   return 1;
 }
 
-/* { dg-final { scan-ipa-dump "Semantic equality hit:f2->f1" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:f1->f2" "icf"  } } */
 /* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf"  } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-7.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-7.c
index 862dd70d50c..488e133d93f 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-icf-7.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-7.c
@@ -68,5 +68,5 @@ int main()
   return 1;
 }
 
-/* { dg-final { scan-ipa-dump "Semantic equality hit:foo2->foo" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:foo->foo2" "icf"  } } */
 /* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf"  } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-8.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-8.c
index 32eed406d53..8ee46d034e7 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-icf-8.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-8.c
@@ -40,5 +40,5 @@ int main(int argc, char **argv)
   printf("fce2: %d\n", fce2(argc, 2 * argc));
 }
 
-/* { dg-final { scan-ipa-dump "Semantic equality hit:fce2->fce1" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:fce1->fce2" "icf"  } } */
 /* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf"  } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/pr64307.c b/gcc/testsuite/gcc.dg/ipa/pr64307.c
index 87537c6113f..79d93af6eb7 100644
--- a/gcc/testsuite/gcc.dg/ipa/pr64307.c
+++ b/gcc/testsuite/gcc.dg/ipa/pr64307.c
@@ -27,5 +27,5 @@ int main()
   return r1 - r2;
 }
 
-/* { dg-final { scan-ipa-dump "Semantic equality hit:real_part_2->real_part" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:real_part->real_part_2" "icf"  } } */
 /* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf"  } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/pr77653.c b/gcc/testsuite/gcc.dg/ipa/pr77653.c
index 16ae510bbb0..f508815a3fb 100644
--- a/gcc/testsuite/gcc.dg/ipa/pr77653.c
+++ b/gcc/testsuite/gcc.dg/ipa/pr77653.c
@@ -21,4 +21,4 @@ int main ()
 }
 
 /* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf"  } } */
-/* { dg-final { scan-ipa-dump "Not unifying; address of original may be compared." "icf"  } } */
+/* { dg-final { scan-ipa-dump "Not unifying; alias cannot be created; target is discardable" "icf"  } } */
-- 
2.11.0

