+2019-06-04 Martin Liska <mliska@suse.cz>
+
+ * ipa-icf.c (sem_item_optimizer::add_item_to_class): Count
+ number of references.
+ (sem_item_optimizer::do_congruence_step):
+ (sem_item_optimizer::worklist_push): Dump how references
+ a class has.
+ (sem_item_optimizer::worklist_pop): Use heap.
+ (sem_item_optimizer::process_cong_reduction): Likewise.
+ * ipa-icf.h: Use fibonacci_heap insteam of std::list.
+
2019-06-04 Martin Liska <mliska@suse.cz>
* ipa-icf.h (struct sem_usage_pair_hash): New.
#include "print-tree.h"
#include "ipa-utils.h"
#include "ipa-icf-gimple.h"
+#include "fibonacci_heap.h"
#include "ipa-icf.h"
#include "stor-layout.h"
#include "dbgcnt.h"
{
item->index_in_class = cls->members.length ();
cls->members.safe_push (item);
+ cls->referenced_by_count += item->referenced_by_count;
item->cls = cls;
}
{
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, " processing congruence step for class: %u "
- "(%u items), index: %u\n", cls->id, cls->members.length (), i);
+ "(%u items, %u references), index: %u\n", cls->id,
+ cls->referenced_by_count, cls->members.length (), i);
do_congruence_step_for_index (cls, i);
if (splitter_class_removed)
return;
cls->in_worklist = true;
- worklist.push_back (cls);
+ worklist.insert (cls->referenced_by_count, cls);
}
/* Pops a class from worklist. */
while (!worklist.empty ())
{
- cls = worklist.front ();
- worklist.pop_front ();
+ cls = worklist.extract_min ();
if (cls->in_worklist)
{
cls->in_worklist = false;
if (dump_file)
fprintf (dump_file, "Worklist has been filled with: %lu\n",
- (unsigned long) worklist.size ());
+ (unsigned long) worklist.nodes ());
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "Congruence class reduction\n");
{
public:
/* Congruence class constructor for a new class with _ID. */
- congruence_class (unsigned int _id): in_worklist (false), id(_id)
+ congruence_class (unsigned int _id): in_worklist (false), id (_id),
+ referenced_by_count (0)
{
}
/* Global unique class identifier. */
unsigned int id;
+
+ /* Total number of references to items of this class. */
+ unsigned referenced_by_count;
};
/* Semantic item type enum. */
/* Worklist of congruence classes that can potentially
refine classes of congruence. */
- std::list<congruence_class *> worklist;
+ fibonacci_heap<unsigned, congruence_class> worklist;
/* Remove semantic ITEM and release memory. */
void remove_item (sem_item *item);