+2017-01-10 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.
+
2017-01-10 Martin Liska <mliska@suse.cz>
* ipa-icf.c (sem_item_optimizer::sem_item_optimizer): Remove
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
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++)
}
}
+ auto_vec <congruence_class_group *> classes (m_classes.elements ());
+ for (hash_table<congruence_class_hash>::iterator it = m_classes.begin ();
+ it != m_classes.end (); ++it)
+ classes.quick_push (*it);
+
+ classes.qsort (sort_congruence_class_groups_by_decl_uid);
+
if (dump_file)
{
fprintf (dump_file, "\nItem count: %u\n", item_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;
+2017-01-10 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.
+
2017-01-10 Andrew Senkevich <andrew.senkevich@intel.com>
* g++.dg/other/i386-2.C: Add -mavx512vpopcntdq.
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" } } */
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" } } */
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" } } */
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" } } */
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" } } */
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" } } */
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" } } */
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" } } */
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" } } */
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" } } */
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" } } */
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" } } */
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" } } */
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" } } */
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" } } */
}
/* { 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" } } */
}
}
/* { 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" } } */
}
}
/* { 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" } } */
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" } } */
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" } } */
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" } } */
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" } } */
}
/* { 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" } } */