+2007-05-24 Zdenek Dvorak <dvorakz@suse.cz>
+
+ PR middle-end/32018
+ * tree-ssa-threadupdate.c (thread_through_loop_header): Use
+ set_loop_copy.
+ (thread_through_all_blocks): Call initialize_original_copy_tables
+ and free_original_copy_tables.
+ * cfgloopmanip.c (duplicate_loop, duplicate_loop_to_header_edge):
+ Use set_loop_copy.
+ * tree-cfg.c (tree_duplicate_sese_region): Ditto.
+ * cfghooks.c (duplicate_block): Use get_loop_copy.
+ * cfg.c: Include cfgloop.h.
+ (loop_copy): New hash table.
+ (initialize_original_copy_tables): Initialize loop_copy table.
+ (free_original_copy_tables): Free loop_copy table.
+ (copy_original_table_clear, copy_original_table_set,
+ set_loop_copy, get_loop_copy): New functions.
+ (set_bb_original, set_bb_copy): Use copy_original_table_set.
+ * cfgloop.h (struct loop): Remove copy field.
+ * Makefile.in (cfg.o): Add CFGLOOP_H dependency.
+ * basic-block.h (set_loop_copy, get_loop_copy): Declare.
+
2007-05-24 H.J. Lu <hongjiu.lu@intel.com>
* config/i386/i386.c (ix86_handle_option): Handle SSE4.1 for
#include "ggc.h"
#include "hashtab.h"
#include "alloc-pool.h"
+#include "cfgloop.h"
/* The obstack on which the flow graph components are allocated. */
copies. */
static htab_t bb_original;
static htab_t bb_copy;
+
+/* And between loops and copies. */
+static htab_t loop_copy;
static alloc_pool original_copy_bb_pool;
struct htab_bb_copy_original_entry
bb_original = htab_create (10, bb_copy_original_hash,
bb_copy_original_eq, NULL);
bb_copy = htab_create (10, bb_copy_original_hash, bb_copy_original_eq, NULL);
+ loop_copy = htab_create (10, bb_copy_original_hash, bb_copy_original_eq, NULL);
}
/* Free the data structures to maintain mapping between blocks and
gcc_assert (original_copy_bb_pool);
htab_delete (bb_copy);
htab_delete (bb_original);
+ htab_delete (loop_copy);
free_alloc_pool (original_copy_bb_pool);
bb_copy = NULL;
bb_original = NULL;
+ loop_copy = NULL;
original_copy_bb_pool = NULL;
}
+/* Removes the value associated with OBJ from table TAB. */
+
+static void
+copy_original_table_clear (htab_t tab, unsigned obj)
+{
+ void **slot;
+ struct htab_bb_copy_original_entry key, *elt;
+
+ if (!original_copy_bb_pool)
+ return;
+
+ key.index1 = obj;
+ slot = htab_find_slot (tab, &key, NO_INSERT);
+ if (!slot)
+ return;
+
+ elt = *slot;
+ htab_clear_slot (tab, slot);
+ pool_free (original_copy_bb_pool, elt);
+}
+
+/* Sets the value associated with OBJ in table TAB to VAL.
+ Do nothing when data structures are not initialized. */
+
+static void
+copy_original_table_set (htab_t tab, unsigned obj, unsigned val)
+{
+ struct htab_bb_copy_original_entry **slot;
+ struct htab_bb_copy_original_entry key;
+
+ if (!original_copy_bb_pool)
+ return;
+
+ key.index1 = obj;
+ slot = (struct htab_bb_copy_original_entry **)
+ htab_find_slot (tab, &key, INSERT);
+ if (!*slot)
+ {
+ *slot = pool_alloc (original_copy_bb_pool);
+ (*slot)->index1 = obj;
+ }
+ (*slot)->index2 = val;
+}
+
/* Set original for basic block. Do nothing when data structures are not
initialized so passes not needing this don't need to care. */
void
set_bb_original (basic_block bb, basic_block original)
{
- if (original_copy_bb_pool)
- {
- struct htab_bb_copy_original_entry **slot;
- struct htab_bb_copy_original_entry key;
-
- key.index1 = bb->index;
- slot =
- (struct htab_bb_copy_original_entry **) htab_find_slot (bb_original,
- &key, INSERT);
- if (*slot)
- (*slot)->index2 = original->index;
- else
- {
- *slot = pool_alloc (original_copy_bb_pool);
- (*slot)->index1 = bb->index;
- (*slot)->index2 = original->index;
- }
- }
+ copy_original_table_set (bb_original, bb->index, original->index);
}
/* Get the original basic block. */
void
set_bb_copy (basic_block bb, basic_block copy)
{
- if (original_copy_bb_pool)
- {
- struct htab_bb_copy_original_entry **slot;
- struct htab_bb_copy_original_entry key;
-
- key.index1 = bb->index;
- slot =
- (struct htab_bb_copy_original_entry **) htab_find_slot (bb_copy,
- &key, INSERT);
- if (*slot)
- (*slot)->index2 = copy->index;
- else
- {
- *slot = pool_alloc (original_copy_bb_pool);
- (*slot)->index1 = bb->index;
- (*slot)->index2 = copy->index;
- }
- }
+ copy_original_table_set (bb_copy, bb->index, copy->index);
}
/* Get the copy of basic block. */
else
return NULL;
}
+
+/* Set copy for LOOP to COPY. Do nothing when data structures are not
+ initialized so passes not needing this don't need to care. */
+
+void
+set_loop_copy (struct loop *loop, struct loop *copy)
+{
+ if (!copy)
+ copy_original_table_clear (loop_copy, loop->num);
+ else
+ copy_original_table_set (loop_copy, loop->num, copy->num);
+}
+
+/* Get the copy of LOOP. */
+
+struct loop *
+get_loop_copy (struct loop *loop)
+{
+ struct htab_bb_copy_original_entry *entry;
+ struct htab_bb_copy_original_entry key;
+
+ gcc_assert (original_copy_bb_pool);
+
+ key.index1 = loop->num;
+ entry = (struct htab_bb_copy_original_entry *) htab_find (loop_copy, &key);
+ if (entry)
+ return get_loop (entry->index2);
+ else
+ return NULL;
+}
/* The duplicate of the header is the new preheader of the loop. Ensure
that it is placed correctly in the loop hierarchy. */
- loop->copy = loop_outer (loop);
+ set_loop_copy (loop, loop_outer (loop));
thread_block (header, false);
- loop->copy = NULL;
+ set_loop_copy (loop, NULL);
new_preheader = e->dest;
/* Create the new latch block. This is always necessary, as the latch
mark_threaded_blocks (threaded_blocks);
- if (current_loops)
- FOR_EACH_LOOP (li, loop, LI_FROM_INNERMOST)
- loop->copy = NULL;
+ initialize_original_copy_tables ();
/* First perform the threading requests that do not affect
loop structure. */
fprintf (dump_file, "\nJumps threaded: %lu\n",
thread_stats.num_threaded_edges);
+ free_original_copy_tables ();
+
BITMAP_FREE (threaded_blocks);
threaded_blocks = NULL;
VEC_free (edge, heap, threaded_edges);