diff options
author | Diego Novillo <dnovillo@redhat.com> | 2006-11-22 02:07:31 +0000 |
---|---|---|
committer | Diego Novillo <dnovillo@redhat.com> | 2006-11-22 02:07:31 +0000 |
commit | 70e2b0f165918f84bb83d2dc4bf05dcdeef60f39 (patch) | |
tree | 64ebb728aceb3433bb5af4d733276af200e687e3 | |
parent | 2a365f55326f5e2051ee4f9f857eec377faee059 (diff) |
* tree-ssa-operands.h (SSA_OPERAND_MEMORY_SIZE): Reduce to 10240.mem-ssa
(struct stmt_operands_d): Add fields 'stores' and 'loads'.
(LOADED_SYMS): Define.
(STORED_SYMS): Define.
(struct mem_syms_map_d): Remove. Update all users.
(get_loads_and_stores): Remove. Update all users to call
LOADED_SYMS or STORED_SYMS accordingly.
(move_loads_and_stores): Remove. Update all users.
(delete_loads_and_stores): Remove. Update all users.
* tree-into-ssa.c (add_new_name_mapping): If a memory mapping
is requested for .MEM, mark the symbols for renaming instead.
(get_reaching_def): If the memory symbol does not have
DECL_INITIAL set, use .MEM's default definition.
(rewrite_update_init_block): If the LHS is a memory partition,
set the PHI node to be the current definition for all the
symbols in the partition.
(rewrite_update_stmt_vops): Always keep default definition for
.MEM.
* tree-flow-inline.h (set_memory_partition): Do not special
case .MEM
* tree-ssa.c (verify_phi_args): Remove argument
PHI_FACTORED_SYMS. Update users.
(create_mem_var): Create .MEM as a MEMORY_PARTITION_TAG.
* tree-ssa-operands.c (mem_syms_tbl): Remove. Update all
users.
(mem_syms_hash): Likewise.
(mem_syms_eq): Likewise.
(mem_syms_free): Likewise.
(get_loads_and_stores): Likewise.
(delete_loads_and_stores): Likewise.
(move_loads_and_stores): Likewise.
(dump_loads_and_stores): Likewise.
(debug_loads_and_stores): Likewise.
(free_ssa_operands): Add argument STMT. If STMT is SIGMA_NODE
do not free the sets of loads and stores.
(update_loads_and_stores): Do not allocate sets of loads and
stores for SIGMA_NODE. Use the symbols in the associated
memory partition.
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/mem-ssa@119086 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog.mem-ssa | 41 | ||||
-rw-r--r-- | gcc/tree-cfg.c | 2 | ||||
-rw-r--r-- | gcc/tree-dfa.c | 5 | ||||
-rw-r--r-- | gcc/tree-flow-inline.h | 5 | ||||
-rw-r--r-- | gcc/tree-into-ssa.c | 114 | ||||
-rw-r--r-- | gcc/tree-phinodes.c | 12 | ||||
-rw-r--r-- | gcc/tree-pretty-print.c | 15 | ||||
-rw-r--r-- | gcc/tree-ssa-loop-im.c | 28 | ||||
-rw-r--r-- | gcc/tree-ssa-operands.c | 283 | ||||
-rw-r--r-- | gcc/tree-ssa-operands.h | 31 | ||||
-rw-r--r-- | gcc/tree-ssa-structalias.c | 8 | ||||
-rw-r--r-- | gcc/tree-ssa.c | 71 | ||||
-rw-r--r-- | gcc/tree-stdarg.c | 12 | ||||
-rw-r--r-- | gcc/tree-vect-transform.c | 1 |
14 files changed, 203 insertions, 425 deletions
diff --git a/gcc/ChangeLog.mem-ssa b/gcc/ChangeLog.mem-ssa index b669befd999..e8285f2d30d 100644 --- a/gcc/ChangeLog.mem-ssa +++ b/gcc/ChangeLog.mem-ssa @@ -1,3 +1,44 @@ +2006-11-21 Diego Novillo <dnovillo@redhat.com> + + * tree-ssa-operands.h (SSA_OPERAND_MEMORY_SIZE): Reduce to 10240. + (struct stmt_operands_d): Add fields 'stores' and 'loads'. + (LOADED_SYMS): Define. + (STORED_SYMS): Define. + (struct mem_syms_map_d): Remove. Update all users. + (get_loads_and_stores): Remove. Update all users to call + LOADED_SYMS or STORED_SYMS accordingly. + (move_loads_and_stores): Remove. Update all users. + (delete_loads_and_stores): Remove. Update all users. + * tree-into-ssa.c (add_new_name_mapping): If a memory mapping + is requested for .MEM, mark the symbols for renaming instead. + (get_reaching_def): If the memory symbol does not have + DECL_INITIAL set, use .MEM's default definition. + (rewrite_update_init_block): If the LHS is a memory partition, + set the PHI node to be the current definition for all the + symbols in the partition. + (rewrite_update_stmt_vops): Always keep default definition for + .MEM. + * tree-flow-inline.h (set_memory_partition): Do not special + case .MEM + * tree-ssa.c (verify_phi_args): Remove argument + PHI_FACTORED_SYMS. Update users. + (create_mem_var): Create .MEM as a MEMORY_PARTITION_TAG. + * tree-ssa-operands.c (mem_syms_tbl): Remove. Update all + users. + (mem_syms_hash): Likewise. + (mem_syms_eq): Likewise. + (mem_syms_free): Likewise. + (get_loads_and_stores): Likewise. + (delete_loads_and_stores): Likewise. + (move_loads_and_stores): Likewise. + (dump_loads_and_stores): Likewise. + (debug_loads_and_stores): Likewise. + (free_ssa_operands): Add argument STMT. If STMT is SIGMA_NODE + do not free the sets of loads and stores. + (update_loads_and_stores): Do not allocate sets of loads and + stores for SIGMA_NODE. Use the symbols in the associated + memory partition. + 2006-11-20 Diego Novillo <dnovillo@redhat.com> Mainline merge as of 2006-11-20 (@119010). diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 6383ef2cf9c..6acdb8d8cfe 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -2868,7 +2868,6 @@ bsi_remove (block_stmt_iterator *i, bool remove_eh_info) mark_stmt_modified (t); if (remove_eh_info) remove_stmt_from_eh_region (t); - delete_loads_and_stores (t); } @@ -2935,7 +2934,6 @@ bsi_replace (const block_stmt_iterator *bsi, tree stmt, bool update_eh_info) } delink_stmt_imm_use (orig_stmt); - delete_loads_and_stores (orig_stmt); *bsi_stmt_ptr (*bsi) = stmt; mark_stmt_modified (stmt); update_modified_stmts (stmt); diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c index 7962c559fce..60e1d37419d 100644 --- a/gcc/tree-dfa.c +++ b/gcc/tree-dfa.c @@ -772,9 +772,8 @@ mark_symbols_for_renaming (tree stmt) if (stmt_references_memory_p (stmt)) { - mem_syms_map_t mp = get_loads_and_stores (stmt); - mark_set_for_renaming (mp->loads); - mark_set_for_renaming (mp->stores); + mark_set_for_renaming (LOADED_SYMS (stmt)); + mark_set_for_renaming (STORED_SYMS (stmt)); } /* Mark all the GIMPLE register operands for renaming. */ diff --git a/gcc/tree-flow-inline.h b/gcc/tree-flow-inline.h index d5530b63b4e..2ec6462b221 100644 --- a/gcc/tree-flow-inline.h +++ b/gcc/tree-flow-inline.h @@ -796,13 +796,12 @@ set_memory_partition (tree sym, tree tag) } /* Return true if NAME is a memory factoring SSA name (i.e., an SSA - name for .MEM or for a memory partition. */ + name for a memory partition. */ static inline bool factoring_name_p (tree name) { - return SSA_NAME_VAR (name) == mem_var - || TREE_CODE (SSA_NAME_VAR (name)) == MEMORY_PARTITION_TAG; + return TREE_CODE (SSA_NAME_VAR (name)) == MEMORY_PARTITION_TAG; } /* Return true if VAR is a clobbered by function calls. */ diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c index 54fe2638628..c49aa118e92 100644 --- a/gcc/tree-into-ssa.c +++ b/gcc/tree-into-ssa.c @@ -667,15 +667,6 @@ add_new_name_mapping (tree new, tree old) /* OLD and NEW must be different SSA names for the same symbol. */ gcc_assert (new != old && SSA_NAME_VAR (new) == SSA_NAME_VAR (old)); - /* We may need to grow NEW_SSA_NAMES and OLD_SSA_NAMES because our - caller may have created new names since the set was created. */ - if (new_ssa_names->n_bits <= num_ssa_names - 1) - { - unsigned int new_sz = num_ssa_names + NAME_SETS_GROWTH_FACTOR; - new_ssa_names = sbitmap_resize (new_ssa_names, new_sz, 0); - old_ssa_names = sbitmap_resize (old_ssa_names, new_sz, 0); - } - /* If this mapping is for virtual names, we will need to update virtual operands. If this is a mapping for .MEM, then we gather the symbols associated with each name. */ @@ -701,24 +692,40 @@ add_new_name_mapping (tree new, tree old) } else { - mem_syms_map_t oldsyms, newsyms; + tree old_stmt, new_stmt; bitmap vs; vs = update_ssa_stats.virtual_symbols; - oldsyms = get_loads_and_stores (SSA_NAME_DEF_STMT (old)); - newsyms = get_loads_and_stores (SSA_NAME_DEF_STMT (new)); + old_stmt = SSA_NAME_DEF_STMT (old); + new_stmt = SSA_NAME_DEF_STMT (new); + + if (LOADED_SYMS (old_stmt)) + bitmap_ior_into (vs, LOADED_SYMS (old_stmt)); - if (oldsyms->loads) - bitmap_ior_into (vs, oldsyms->loads); + if (STORED_SYMS (old_stmt)) + bitmap_ior_into (vs, STORED_SYMS (old_stmt)); - if (oldsyms->stores) - bitmap_ior_into (vs, oldsyms->stores); + if (STORED_SYMS (new_stmt)) + bitmap_ior_into (vs, STORED_SYMS (new_stmt)); - if (newsyms->stores) - bitmap_ior_into (vs, newsyms->stores); + if (sym == mem_var) + { + bitmap_ior_into (syms_to_rename, vs); + timevar_pop (TV_TREE_SSA_INCREMENTAL); + return; + } } } + /* We may need to grow NEW_SSA_NAMES and OLD_SSA_NAMES because our + caller may have created new names since the set was created. */ + if (new_ssa_names->n_bits <= num_ssa_names - 1) + { + unsigned int new_sz = num_ssa_names + NAME_SETS_GROWTH_FACTOR; + new_ssa_names = sbitmap_resize (new_ssa_names, new_sz, 0); + old_ssa_names = sbitmap_resize (old_ssa_names, new_sz, 0); + } + /* Update the REPL_TBL table. */ add_to_repl_tbl (new, old); @@ -1362,6 +1369,20 @@ get_reaching_def (tree var) if (currdef == NULL_TREE) { tree sym = DECL_P (var) ? var : SSA_NAME_VAR (var); + + if (!is_gimple_reg (sym)) + { + /* For memory symbols, use .MEM's default definition to + serve as the default definition for SYM. However, using + a common default definition may interfere with constant + propagation when the symbol has an initial value (because + CCP cannot find DECL_INITIAL for the original symbol). + So, if SYM has a non-empty DECL_INITIAL, we use SYM + itself. */ + if (MTAG_P (sym) || DECL_INITIAL (sym) == NULL_TREE) + sym = mem_var; + } + currdef = get_default_def_for (sym); set_current_def (var, currdef); } @@ -1871,7 +1892,7 @@ rewrite_update_init_block (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED, } else if (symbol_marked_for_renaming (lhs_sym)) { - if (is_gimple_reg (lhs_sym)) + if (TREE_CODE (lhs_sym) != MEMORY_PARTITION_TAG) { /* If LHS is a regular symbol marked for renaming, register LHS as its current reaching definition. */ @@ -1886,7 +1907,7 @@ rewrite_update_init_block (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED, unsigned i; bitmap syms; - syms = get_loads_and_stores (phi)->stores; + syms = MPT_SYMBOLS (lhs_sym); EXECUTE_IF_AND_IN_BITMAP (syms, mem_syms_to_rename, 0, i, bi) register_new_update_single (lhs, referenced_var (i)); } @@ -2143,10 +2164,15 @@ rewrite_update_stmt_vops (tree stmt, bitmap syms, bitmap rdefs, int which_vops) if (sym == mem_var && !name_marked_for_release_p (name)) { - tree def_stmt = SSA_NAME_DEF_STMT (name); - bitmap syms = get_loads_and_stores (def_stmt)->stores; - if (!bitmap_intersect_p (syms, mem_syms_to_rename)) + if (SSA_NAME_IS_DEFAULT_DEF (name)) bitmap_set_bit (rdefs, SSA_NAME_VERSION (name)); + else + { + tree def_stmt = SSA_NAME_DEF_STMT (name); + bitmap syms = STORED_SYMS (def_stmt); + if (!bitmap_intersect_p (syms, mem_syms_to_rename)) + bitmap_set_bit (rdefs, SSA_NAME_VERSION (name)); + } } else if (TREE_CODE (sym) == MEMORY_PARTITION_TAG) { @@ -2236,31 +2262,30 @@ register_new_vdef_name (tree stmt, bitmap stores) static void rewrite_update_memory_stmt (tree stmt) { - bitmap rdefs; - mem_syms_map_t syms; - - syms = get_loads_and_stores (stmt); + bitmap rdefs, loads, stores; - if (syms->loads == NULL && syms->stores == NULL) + if (LOADED_SYMS (stmt) == NULL && STORED_SYMS (stmt) == NULL) return; rdefs = BITMAP_ALLOC (NULL); + loads = LOADED_SYMS (stmt); + stores = STORED_SYMS (stmt); /* Rewrite loaded symbols marked for renaming. */ - if (syms->loads && bitmap_intersect_p (syms->loads, mem_syms_to_rename)) + if (loads && bitmap_intersect_p (loads, mem_syms_to_rename)) { - rewrite_update_stmt_vops (stmt, syms->loads, rdefs, SSA_OP_VUSE); + rewrite_update_stmt_vops (stmt, loads, rdefs, SSA_OP_VUSE); bitmap_clear (rdefs); } - if (syms->stores && bitmap_intersect_p (syms->stores, mem_syms_to_rename)) + if (stores && bitmap_intersect_p (stores, mem_syms_to_rename)) { /* Rewrite stored symbols marked for renaming. */ - rewrite_update_stmt_vops (stmt, syms->stores, rdefs, SSA_OP_VMAYUSE); + rewrite_update_stmt_vops (stmt, stores, rdefs, SSA_OP_VMAYUSE); /* Register the LHS of the VDEF to be the new reaching definition of all the symbols in STORES. */ - register_new_vdef_name (stmt, syms->stores); + register_new_vdef_name (stmt, stores); } BITMAP_FREE (rdefs); @@ -2373,8 +2398,8 @@ replace_factored_phi_argument (tree phi, edge e) tree rdef, last_rdef, lhs_sym; bool all_default_rdefs_p; - phi_syms = get_loads_and_stores (phi)->stores; lhs_sym = SSA_NAME_VAR (PHI_RESULT (phi)); + phi_syms = MPT_SYMBOLS (lhs_sym); gcc_assert (bitmap_intersect_p (phi_syms, mem_syms_to_rename)); /* Traverse all the symbols factored in PHI to see if we need to @@ -2460,13 +2485,13 @@ rewrite_update_phi_arguments (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED, /* Process old SSA names first. */ SET_USE (arg_p, get_reaching_def (arg)); } - else if (stmt_references_memory_p (phi) - && bitmap_intersect_p (get_loads_and_stores (phi)->stores, + else if (TREE_CODE (lhs_sym) == MEMORY_PARTITION_TAG + && bitmap_intersect_p (MPT_SYMBOLS (lhs_sym), mem_syms_to_rename)) { /* If this is a factored PHI node, the argument may have multiple reaching definitions, which will - require this PHI node to be split up. */ + require a SIGMA node in E->SRC. */ replace_factored_phi_argument (phi, e); } else @@ -2906,16 +2931,15 @@ prepare_block_for_update (basic_block bb, bool insert_phi_p) { bitmap_iterator bi; unsigned i; - mem_syms_map_t syms = get_loads_and_stores (stmt); prune_stale_vops (stmt); /* FIXME. Maybe it's faster to traverse VUSE/VDEF operands instead of the symbols. Although, the first time we are renaming, we will not have any operands. */ - if (syms->stores - && bitmap_intersect_p (syms->stores, mem_syms_to_rename)) - EXECUTE_IF_AND_IN_BITMAP (syms->stores, mem_syms_to_rename, + if (STORED_SYMS (stmt) + && bitmap_intersect_p (STORED_SYMS (stmt), mem_syms_to_rename)) + EXECUTE_IF_AND_IN_BITMAP (STORED_SYMS (stmt), mem_syms_to_rename, 0, i, bi) { tree mpt = memory_partition (referenced_var (i)); @@ -2923,9 +2947,9 @@ prepare_block_for_update (basic_block bb, bool insert_phi_p) mark_def_interesting (mpt, stmt, bb, insert_phi_p); } - if (syms->loads - && bitmap_intersect_p (syms->loads, mem_syms_to_rename)) - EXECUTE_IF_AND_IN_BITMAP (syms->loads, mem_syms_to_rename, + if (LOADED_SYMS (stmt) + && bitmap_intersect_p (LOADED_SYMS (stmt), mem_syms_to_rename)) + EXECUTE_IF_AND_IN_BITMAP (LOADED_SYMS (stmt), mem_syms_to_rename, 0, i, bi) { tree mpt = memory_partition (referenced_var (i)); @@ -2959,7 +2983,7 @@ prepare_block_for_update (basic_block bb, bool insert_phi_p) { unsigned i; bitmap_iterator bi; - bitmap stores = get_loads_and_stores (last)->stores; + bitmap stores = STORED_SYMS (last); EXECUTE_IF_SET_IN_BITMAP (mem_syms_to_rename, 0, i, bi) { diff --git a/gcc/tree-phinodes.c b/gcc/tree-phinodes.c index 73007e91378..f0dc475b549 100644 --- a/gcc/tree-phinodes.c +++ b/gcc/tree-phinodes.c @@ -253,8 +253,6 @@ release_phi_node (tree phi) delink_imm_use (imm); } - delete_loads_and_stores (phi); - bucket = len > NUM_BUCKETS - 1 ? NUM_BUCKETS - 1 : len; bucket -= 2; PHI_CHAIN (phi) = free_phinodes[bucket]; @@ -304,9 +302,6 @@ resize_phi_node (tree *phi, int len) imm->stmt = new_phi; } - if (stmt_references_memory_p (*phi)) - move_loads_and_stores (new_phi, *phi); - *phi = new_phi; } @@ -356,6 +351,13 @@ create_phi_node (tree var, basic_block bb) { tree phi; +#if defined ENABLE_CHECKING + if (TREE_CODE (var) != SSA_NAME) + gcc_assert (var != mem_var); + else + gcc_assert (SSA_NAME_VAR (var) != mem_var); +#endif + phi = make_phi_node (var, EDGE_COUNT (bb->preds)); /* Add the new PHI node to the list of PHI nodes for block BB. */ diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c index f40c4e4cb5d..eae99d9cdc6 100644 --- a/gcc/tree-pretty-print.c +++ b/gcc/tree-pretty-print.c @@ -455,7 +455,7 @@ dump_sigma_node (pretty_printer *buffer, tree sigma, int spc, int flags) pp_string (buffer, ">"); if (flags & TDF_MEMSYMS) - dump_symbols (buffer, get_loads_and_stores (sigma)->stores, flags); + dump_symbols (buffer, STORED_SYMS (sigma), flags); } else { @@ -1691,7 +1691,7 @@ dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags, pp_string (buffer, ">"); if (stmt_references_memory_p (node) && (flags & TDF_MEMSYMS)) - dump_symbols (buffer, get_loads_and_stores (node)->stores, flags); + dump_symbols (buffer, STORED_SYMS (node), flags); } break; @@ -2698,13 +2698,10 @@ dump_vops (pretty_printer *buffer, tree stmt, int spc, int flags) struct vdef_optype_d *vdefs; struct vuse_optype_d *vuses; size_t i, n; - mem_syms_map_t syms; if (!ssa_operands_active () || !stmt_references_memory_p (stmt)) return; - syms = (flags & TDF_MEMSYMS) ? get_loads_and_stores (stmt) : NULL; - vuses = VUSE_OPS (stmt); if (vuses) { @@ -2720,8 +2717,8 @@ dump_vops (pretty_printer *buffer, tree stmt, int spc, int flags) pp_string (buffer, ">"); - if (syms) - dump_symbols (buffer, syms->loads, flags); + if (flags & TDF_MEMSYMS) + dump_symbols (buffer, LOADED_SYMS (stmt), flags); newline_and_indent (buffer, spc); } @@ -2743,8 +2740,8 @@ dump_vops (pretty_printer *buffer, tree stmt, int spc, int flags) pp_string (buffer, ">"); - if (syms) - dump_symbols (buffer, syms->stores, flags); + if (flags & TDF_MEMSYMS) + dump_symbols (buffer, STORED_SYMS (stmt), flags); newline_and_indent (buffer, spc); } diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c index e69731bec13..db7ba9875f4 100644 --- a/gcc/tree-ssa-loop-im.c +++ b/gcc/tree-ssa-loop-im.c @@ -897,13 +897,10 @@ free_mem_ref_locs (struct mem_ref_loc *mem_refs) static void rewrite_mem_refs (tree tmp_var, struct mem_ref_loc *mem_refs) { - mem_syms_map_t mp; - for (; mem_refs; mem_refs = mem_refs->next) { - mp = get_loads_and_stores (mem_refs->stmt); - mark_set_for_renaming (mp->stores); - mark_set_for_renaming (mp->loads); + mark_set_for_renaming (STORED_SYMS (mem_refs->stmt)); + mark_set_for_renaming (LOADED_SYMS (mem_refs->stmt)); *mem_refs->ref = tmp_var; update_stmt (mem_refs->stmt); } @@ -1192,7 +1189,6 @@ gather_mem_refs_stmt (struct loop *loop, htab_t mem_refs, PTR *slot; struct mem_ref *ref = NULL; bool is_stored; - mem_syms_map_t mp; if (ZERO_SSA_OPERANDS (stmt, SSA_OP_ALL_VIRTUALS)) return; @@ -1249,25 +1245,21 @@ gather_mem_refs_stmt (struct loop *loop, htab_t mem_refs, } ref->is_stored |= is_stored; - mp = get_loads_and_stores (stmt); - - if (mp->loads) - bitmap_ior_into (ref->vops, mp->loads); + if (LOADED_SYMS (stmt)) + bitmap_ior_into (ref->vops, LOADED_SYMS (stmt)); - if (mp->stores) - bitmap_ior_into (ref->vops, mp->stores); + if (STORED_SYMS (stmt)) + bitmap_ior_into (ref->vops, STORED_SYMS (stmt)); record_mem_ref_loc (&ref->locs, stmt, mem); return; fail: - mp = get_loads_and_stores (stmt); - - if (mp->loads) - bitmap_ior_into (clobbered_vops, mp->loads); + if (LOADED_SYMS (stmt)) + bitmap_ior_into (clobbered_vops, LOADED_SYMS (stmt)); - if (mp->stores) - bitmap_ior_into (clobbered_vops, mp->stores); + if (STORED_SYMS (stmt)) + bitmap_ior_into (clobbered_vops, STORED_SYMS (stmt)); } /* Gathers memory references in LOOP. Notes vops accessed through unrecognized diff --git a/gcc/tree-ssa-operands.c b/gcc/tree-ssa-operands.c index 8fae420b14b..bae6360ac9a 100644 --- a/gcc/tree-ssa-operands.c +++ b/gcc/tree-ssa-operands.c @@ -204,63 +204,10 @@ DEF_VEC_ALLOC_P(scb_t,heap); of changes for the popped statement. */ static VEC(scb_t,heap) *scb_stack; -/* Table, indexed by statement, for symbols loaded and stored by - statements that reference memory. */ -static htab_t mem_syms_tbl; - /* Table of memory partitions. Indexed according to the partitioning scheme defined in get_mpt_for. */ static VEC(tree,heap) *mpt_table; -/* Hashing and equality functions for MEM_SYMS_TBL. */ - -static hashval_t -mem_syms_hash (const void *p) -{ - return htab_hash_pointer ((const void *)((const mem_syms_map_t)p)->stmt); -} - -static int -mem_syms_eq (const void *p1, const void *p2) -{ - return ((const mem_syms_map_t)p1)->stmt == ((const mem_syms_map_t)p2)->stmt; -} - -static void -mem_syms_free (void *p) -{ - tree stmt = ((mem_syms_map_t) p)->stmt; - bitmap loads = ((mem_syms_map_t) p)->loads; - bitmap stores = ((mem_syms_map_t) p)->stores; - - if (TREE_CODE (stmt) == PHI_NODE) - { - /* Do not free loads for PHI nodes for memory partitions. - These PHI nodes take their sets from the memory partition - that they represent. */ - tree lhs_sym = SSA_NAME_VAR (PHI_RESULT (stmt)); - if (TREE_CODE (lhs_sym) != MEMORY_PARTITION_TAG) - BITMAP_FREE (loads); - } - else if (TREE_CODE (stmt) == SIGMA_NODE) - { - /* SIGMA nodes always take their loads/stores sets from the - associated memory partition, so they should not be - deallocated. */ - ; - } - else - { - bool shared_p = (loads == stores); - - BITMAP_FREE (loads); - if (!shared_p) - BITMAP_FREE (stores); - } - - free (p); -} - /* Return true if the parser should just gather symbols loaded/stored by the statement instead of scanning for operands. */ @@ -356,8 +303,6 @@ init_ssa_operands (void) scb_stack = VEC_alloc (scb_t, heap, 20); gcc_assert (operand_memory == NULL); operand_memory_index = SSA_OPERAND_MEMORY_SIZE; - gcc_assert (mem_syms_tbl == NULL); - mem_syms_tbl = htab_create (200, mem_syms_hash, mem_syms_eq, mem_syms_free); gcc_assert (mpt_table == NULL); ops_active = true; @@ -393,9 +338,6 @@ fini_ssa_operands (void) ggc_free (ptr); } - htab_delete (mem_syms_tbl); - mem_syms_tbl = NULL; - for (ix = 0; VEC_iterate (tree, mpt_table, ix, mpt); ix++) if (mpt) BITMAP_FREE (MPT_SYMBOLS (mpt)); @@ -2365,123 +2307,17 @@ build_ssa_operands (tree stmt) /* Free any operands vectors in OPS. */ void -free_ssa_operands (stmt_operands_p ops) +free_ssa_operands (tree stmt, stmt_operands_p ops) { ops->def_ops = NULL; ops->use_ops = NULL; ops->vdef_ops = NULL; ops->vuse_ops = NULL; -} - - -/* Lookup in MEM_SYMS_TBL a slot corresponding to STMT. Create a new - one if needed. */ - -mem_syms_map_t -get_loads_and_stores (tree stmt) -{ - struct mem_syms_map_d m, *mp; - void **slot; - - gcc_assert (mem_syms_tbl); - gcc_assert (stmt_references_memory_p (stmt)); - - m.stmt = stmt; - slot = htab_find_slot (mem_syms_tbl, (void *) &m, INSERT); - if (*slot == NULL) + if (TREE_CODE (stmt) != SIGMA_NODE) { - mp = XNEW (struct mem_syms_map_d); - mp->stmt = stmt; - - if (TREE_CODE (stmt) == PHI_NODE) - { - tree lhs_sym; - - /* Non-factored PHI nodes load and store exactly one symbol. */ - lhs_sym = SSA_NAME_VAR (PHI_RESULT (stmt)); - if (TREE_CODE (lhs_sym) == MEMORY_PARTITION_TAG) - mp->loads = MPT_SYMBOLS (lhs_sym); - else - { - mp->loads = BITMAP_ALLOC (NULL); - - /* .MEM PHIs do not factor any symbol. */ - if (lhs_sym != mem_var) - bitmap_set_bit (mp->loads, DECL_UID (lhs_sym)); - } - - /* PHI nodes load and store the same symbols. */ - mp->stores = mp->loads; - } - else if (TREE_CODE (stmt) == SIGMA_NODE) - { - /* SIGMA nodes take their loads/stores sets directly from the - associated partition. */ - mp->loads = NULL; - mp->stores = MPT_SYMBOLS (SIGMA_MPT (stmt)); - } - else - { - mp->loads = BITMAP_ALLOC (NULL); - mp->stores = BITMAP_ALLOC (NULL); - } - - *slot = (void *) mp; + BITMAP_FREE (ops->loads); + BITMAP_FREE (ops->stores); } - else - mp = (mem_syms_map_t) *slot; - - return mp; -} - - -/* Delete the loads and stores sets associated with STMT. */ - -void -delete_loads_and_stores (tree stmt) -{ - if (mem_syms_tbl) - { - struct mem_syms_map_d m; - void **slot; - - m.stmt = stmt; - slot = htab_find_slot (mem_syms_tbl, (void *) &m, NO_INSERT); - if (slot) - htab_remove_elt (mem_syms_tbl, *slot); - } -} - - -/* Move the sets of loads and stores from OLD_STMT into NEW_STMT. - Remove the entry for OLD_STMT. */ - -void -move_loads_and_stores (tree new_stmt, tree old_stmt) -{ - void **slot; - mem_syms_map_t old_mp, new_mp; - - gcc_assert (TREE_CODE (new_stmt) == TREE_CODE (old_stmt)); - - old_mp = get_loads_and_stores (old_stmt); - - if (TREE_CODE (new_stmt) != SIGMA_NODE - && !(TREE_CODE (new_stmt) == PHI_NODE - && TREE_CODE (SSA_NAME_VAR (PHI_RESULT (new_stmt))) - == MEMORY_PARTITION_TAG)) - { - new_mp = get_loads_and_stores (new_stmt); - - bitmap_copy (new_mp->loads, old_mp->loads); - - /* PHI nodes share their loads and stores sets. */ - if (TREE_CODE (new_stmt) != PHI_NODE) - bitmap_copy (new_mp->stores, old_mp->stores); - } - - slot = htab_find_slot (mem_syms_tbl, (void *) old_mp, NO_INSERT); - htab_remove_elt (mem_syms_tbl, *slot); } @@ -2494,30 +2330,32 @@ move_loads_and_stores (tree new_stmt, tree old_stmt) static void update_loads_and_stores (tree stmt) { - mem_syms_map_t mp; + stmt_ann_t ann = stmt_ann (stmt); /* SIGMA nodes do not need scanning, the set of loads and stores is taken directly from the associated memory partition. */ if (TREE_CODE (stmt) == SIGMA_NODE) - return; + { + ann->operands.loads = NULL; + ann->operands.stores = MPT_SYMBOLS (SIGMA_MPT (stmt)); + return; + } memset (&clobber_stats, 0, sizeof (clobber_stats)); - mp = get_loads_and_stores (stmt); - - if (mp->loads) - bitmap_clear (mp->loads); + if (ann->operands.loads) + bitmap_clear (ann->operands.loads); else - mp->loads = BITMAP_ALLOC (NULL); + ann->operands.loads = BITMAP_ALLOC (NULL); - if (mp->stores) - bitmap_clear (mp->stores); + if (ann->operands.stores) + bitmap_clear (ann->operands.stores); else - mp->stores = BITMAP_ALLOC (NULL); + ann->operands.stores = BITMAP_ALLOC (NULL); /* Point the internal loaded/stored sets to the ones provided. */ - loaded_syms = mp->loads; - stored_syms = mp->stores; + loaded_syms = ann->operands.loads; + stored_syms = ann->operands.stores; /* Parse the statement. We don't really care for its operands, so there's no need to initialize anything. If any operand was added @@ -2533,14 +2371,11 @@ update_loads_and_stores (tree stmt) loaded_syms = NULL; stored_syms = NULL; - if (dump_file && (dump_flags & TDF_DETAILS)) - dump_loads_and_stores (dump_file, stmt); + if (ann->operands.loads && bitmap_empty_p (ann->operands.loads)) + ann->operands.loads = NULL; - if (mp->loads && bitmap_empty_p (mp->loads)) - BITMAP_FREE (mp->loads); - - if (mp->stores && bitmap_empty_p (mp->stores)) - BITMAP_FREE (mp->stores); + if (ann->operands.stores && bitmap_empty_p (ann->operands.stores)) + ann->operands.stores = NULL; if (dump_file && (dump_flags & TDF_STATS)) { @@ -2920,44 +2755,6 @@ debug_immediate_uses_for (tree var) } -/* Dump symbols loaded and stored by STMT to FILE. */ - -void -dump_loads_and_stores (FILE *file, tree stmt) -{ - mem_syms_map_t mp; - - print_generic_stmt (file, stmt, TDF_VOPS); - - mp = get_loads_and_stores (stmt); - - if (TREE_CODE (stmt) == PHI_NODE) - { - fprintf (file, "\tLOADS/STORES: "); - dump_decl_set (file, mp->loads); - if (mp->loads != mp->stores) - fprintf (file, "\n\tWARNING. LOADS and STORES sets not shared.\n"); - } - else - { - fprintf (file, "\tLOADS: "); - dump_decl_set (file, mp->loads); - - fprintf (file, "\tSTORES: "); - dump_decl_set (file, mp->stores); - } -} - - -/* Dump symbols loaded and stored by STMT to stderr. */ - -void -debug_loads_and_stores (tree stmt) -{ - dump_loads_and_stores (stderr, stmt); -} - - /* Create a new change buffer for the statement pointed by STMT_P and push the buffer into SCB_STACK. Each change buffer records state information needed to determine what changed in the @@ -2984,18 +2781,14 @@ push_stmt_changes (tree *stmt_p) if (stmt_references_memory_p (stmt)) { - mem_syms_map_t mp; - buf->loads = BITMAP_ALLOC (NULL); buf->stores = BITMAP_ALLOC (NULL); - mp = get_loads_and_stores (stmt); - - if (mp->loads) - bitmap_copy (buf->loads, mp->loads); + if (LOADED_SYMS (stmt)) + bitmap_copy (buf->loads, LOADED_SYMS (stmt)); - if (mp->stores) - bitmap_copy (buf->stores, mp->stores); + if (STORED_SYMS (stmt)) + bitmap_copy (buf->stores, STORED_SYMS (stmt)); } VEC_safe_push (scb_t, heap, scb_stack, buf); @@ -3040,7 +2833,6 @@ pop_stmt_changes (tree *stmt_p) { tree op, stmt; ssa_op_iter iter; - mem_syms_map_t mp; bitmap loads, stores; scb_t buf; @@ -3069,9 +2861,8 @@ pop_stmt_changes (tree *stmt_p) { bitmap factored_by_stmt, factored_by_vops; - mp = get_loads_and_stores (stmt); - loads = mp->loads; - stores = mp->stores; + loads = LOADED_SYMS (stmt); + stores = STORED_SYMS (stmt); /* Gather all the symbols factored by the virtual operands. Mark for renaming any symbol in STMT that is no longer @@ -3079,11 +2870,11 @@ pop_stmt_changes (tree *stmt_p) factored_by_vops = BITMAP_ALLOC (NULL); factored_by_stmt = BITMAP_ALLOC (NULL); - if (mp->loads) - bitmap_ior_into (factored_by_stmt, mp->loads); + if (loads) + bitmap_ior_into (factored_by_stmt, loads); - if (mp->stores) - bitmap_ior_into (factored_by_stmt, mp->stores); + if (stores) + bitmap_ior_into (factored_by_stmt, stores); /* Gather all the symbols factored by the names in VOPS. */ FOR_EACH_SSA_TREE_OPERAND (op, stmt, iter, SSA_OP_VIRTUAL_USES) @@ -3105,8 +2896,9 @@ pop_stmt_changes (tree *stmt_p) bitmap_ior_into (factored_by_vops, factored_by_stmt); else { - syms = get_loads_and_stores (SSA_NAME_DEF_STMT (op))->stores; - bitmap_ior_into (factored_by_vops, syms); + syms = STORED_SYMS (SSA_NAME_DEF_STMT (op)); + if (syms) + bitmap_ior_into (factored_by_vops, syms); } } else if (TREE_CODE (op_sym) == MEMORY_PARTITION_TAG) @@ -3166,7 +2958,7 @@ stmt_references_memory_p (tree stmt) return false; if (TREE_CODE (stmt) == PHI_NODE) - return !is_gimple_reg (SSA_NAME_VAR (PHI_RESULT (stmt))); + return TREE_CODE (SSA_NAME_VAR (PHI_RESULT (stmt))) == MEMORY_PARTITION_TAG; return stmt_ann (stmt)->references_memory; } @@ -3205,13 +2997,10 @@ prune_stale_vops (tree stmt) vuse_optype_p vuses; int i; unsigned ix; - mem_syms_map_t syms; tree op; gcc_assert (stmt_references_memory_p (stmt)); - syms = get_loads_and_stores (stmt); - vdefs = VDEF_OPS (stmt); if (vdefs) { diff --git a/gcc/tree-ssa-operands.h b/gcc/tree-ssa-operands.h index 91514873402..5fa7f310b43 100644 --- a/gcc/tree-ssa-operands.h +++ b/gcc/tree-ssa-operands.h @@ -104,7 +104,7 @@ struct vuse_optype_d typedef struct vuse_optype_d *vuse_optype_p; -#define SSA_OPERAND_MEMORY_SIZE (102400 - sizeof (void *)) +#define SSA_OPERAND_MEMORY_SIZE (10240 - sizeof (void *)) struct ssa_operand_memory_d GTY((chain_next("%h.next"))) { @@ -123,6 +123,10 @@ struct stmt_operands_d /* Virtual operands (VDEF, VUSE). */ struct vdef_optype_d * vdef_ops; struct vuse_optype_d * vuse_ops; + + /* Sets of memory symbols loaded and stored. */ + bitmap stores; + bitmap loads; }; typedef struct stmt_operands_d *stmt_operands_p; @@ -139,6 +143,16 @@ typedef struct stmt_operands_d *stmt_operands_p; #define VUSE_OPS(STMT) (stmt_ann (STMT)->operands.vuse_ops) #define VDEF_OPS(STMT) (stmt_ann (STMT)->operands.vdef_ops) +#define LOADED_SYMS(STMT) \ + ((TREE_CODE (STMT) == PHI_NODE) \ + ? (MPT_SYMBOLS (SSA_NAME_VAR (PHI_RESULT (STMT)))) \ + : (stmt_ann (STMT)->operands.loads)) + +#define STORED_SYMS(STMT) \ + ((TREE_CODE (STMT) == PHI_NODE) \ + ? (MPT_SYMBOLS (SSA_NAME_VAR (PHI_RESULT (STMT)))) \ + : (stmt_ann (STMT)->operands.stores)) + #define USE_OP_PTR(OP) (&((OP)->use_ptr)) #define USE_OP(OP) (USE_FROM_PTR (USE_OP_PTR (OP))) @@ -177,7 +191,7 @@ extern struct vuse_optype_d *realloc_vuse (struct vuse_optype_d *, int); extern void init_ssa_operands (void); extern void fini_ssa_operands (void); -extern void free_ssa_operands (stmt_operands_p); +extern void free_ssa_operands (tree, stmt_operands_p); extern void update_stmt_operands (tree); extern bool verify_imm_links (FILE *f, tree var); @@ -328,19 +342,6 @@ typedef struct ssa_operand_iterator_d /* This macro counts the number of operands in STMT matching FLAGS. */ #define NUM_SSA_OPERANDS(STMT, FLAGS) num_ssa_operands (STMT, FLAGS) -/* Mapping between a statement and the symbols referenced by it. */ -struct mem_syms_map_d -{ - tree stmt; - bitmap loads; - bitmap stores; -}; - -typedef struct mem_syms_map_d *mem_syms_map_t; - -extern mem_syms_map_t get_loads_and_stores (tree); -extern void move_loads_and_stores (tree, tree); -extern void delete_loads_and_stores (tree); extern tree get_mpt_for (tree); extern void dump_memory_partitions (FILE *); extern void debug_memory_partitions (void); diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index 8b11a071afd..d5bdd0d0048 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -3255,12 +3255,8 @@ update_alias_info (tree stmt, struct alias_info *ai) } /* Mark variables in VDEF operands as being written to. */ - if (stmt_references_memory_p (stmt)) - { - mem_syms_map_t mp = get_loads_and_stores (stmt); - if (mp->stores) - bitmap_ior_into (ai->written_vars, mp->stores); - } + if (stmt_references_memory_p (stmt) && STORED_SYMS (stmt)) + bitmap_ior_into (ai->written_vars, STORED_SYMS (stmt)); } diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index 978cbf7637d..e262745027c 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -312,14 +312,10 @@ verify_use (basic_block bb, basic_block def_bb, use_operand_p use_p, DEFINITION_BLOCK is an array of basic blocks indexed by SSA_NAME version numbers. If DEFINITION_BLOCK[SSA_NAME_VERSION] is set, it means that the block in that array slot contains the - definition of SSA_NAME. - - PHI_FACTORED_SYMS is the set of symbols factored by previous PHI - nodes in BB. */ + definition of SSA_NAME. */ static bool -verify_phi_args (tree phi, basic_block bb, basic_block *definition_block, - bitmap phi_factored_syms) +verify_phi_args (tree phi, basic_block bb, basic_block *definition_block) { edge e; bool err = false; @@ -332,52 +328,6 @@ verify_phi_args (tree phi, basic_block bb, basic_block *definition_block, goto error; } - if (stmt_references_memory_p (phi)) - { - bitmap_iterator bi; - unsigned i; - tree lhs; - mem_syms_map_t syms_phi; - - lhs = PHI_RESULT (phi); - syms_phi = get_loads_and_stores (phi); - if (syms_phi->loads != syms_phi->stores) - { - error ("Sets of loads and stores should be shared"); - err = true; - goto error; - } - - EXECUTE_IF_SET_IN_BITMAP (syms_phi->stores, 0, i, bi) - if (is_gimple_reg (referenced_var (i))) - { - error ("Found GIMPLE register in set of stored memory symbols"); - fprintf (stderr, "Symbol: "); - print_generic_stmt (stderr, referenced_var (i), 0); - err = true; - } - - if (bitmap_intersect_p (syms_phi->stores, phi_factored_syms)) - { - bitmap set = BITMAP_ALLOC (NULL); - bitmap_and (set, syms_phi->stores, phi_factored_syms); - error ("Found more than one memory PHI node associated to the " - "same symbol(s)"); - fprintf (stderr, "Symbols: "); - dump_decl_set (stderr, set); - BITMAP_FREE (set); - err = true; - } - - /* If this is a factored PHI node, collect the factored symbols - to check if they are factored multiple times. */ - if (SSA_NAME_VAR (lhs) == mem_var) - bitmap_ior_into (phi_factored_syms, syms_phi->stores); - - if (err) - goto error; - } - for (i = 0; i < phi_num_args; i++) { use_operand_p op_p = PHI_ARG_DEF_PTR (phi, i); @@ -742,7 +692,6 @@ verify_ssa (bool check_modified_stmt) tree op; enum dom_state orig_dom_state = dom_computed[CDI_DOMINATORS]; bitmap names_defined_in_bb = BITMAP_ALLOC (NULL); - bitmap phi_factored_syms = BITMAP_ALLOC (NULL); bitmap mem_syms_found = BITMAP_ALLOC (NULL); gcc_assert (!need_ssa_update_p ()); @@ -796,13 +745,12 @@ verify_ssa (bool check_modified_stmt) /* Verify the arguments for every PHI node in the block. */ for (phi = phi_nodes (bb); phi; phi = PHI_CHAIN (phi)) { - if (verify_phi_args (phi, bb, definition_block, phi_factored_syms)) + if (verify_phi_args (phi, bb, definition_block)) goto err; bitmap_set_bit (names_defined_in_bb, SSA_NAME_VERSION (PHI_RESULT (phi))); } - bitmap_clear (phi_factored_syms); /* Now verify all the uses and vuses in every statement of the block. */ for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi)) @@ -892,7 +840,6 @@ verify_ssa (bool check_modified_stmt) dom_computed[CDI_DOMINATORS] = orig_dom_state; BITMAP_FREE (names_defined_in_bb); - BITMAP_FREE (phi_factored_syms); BITMAP_FREE (mem_syms_found); timevar_pop (TV_TREE_SSA_VERIFY); return; @@ -928,16 +875,10 @@ int_tree_map_hash (const void *item) static void create_mem_var (void) { - mem_var = build_decl (VAR_DECL, get_identifier (".MEM"), void_type_node); - DECL_ARTIFICIAL (mem_var) = 1; - TREE_READONLY (mem_var) = 0; - DECL_EXTERNAL (mem_var) = 1; - TREE_STATIC (mem_var) = 1; - TREE_USED (mem_var) = 1; - DECL_CONTEXT (mem_var) = NULL_TREE; - TREE_THIS_VOLATILE (mem_var) = 0; + mem_var = create_tag_raw (MEMORY_PARTITION_TAG, void_type_node, ".MEM"); TREE_ADDRESSABLE (mem_var) = 0; create_var_ann (mem_var); + MPT_SYMBOLS (mem_var) = NULL_TREE; } @@ -991,7 +932,7 @@ delete_tree_ssa (void) tree stmt = bsi_stmt (bsi); stmt_ann_t ann = get_stmt_ann (stmt); - free_ssa_operands (&ann->operands); + free_ssa_operands (stmt, &ann->operands); ann->addresses_taken = 0; mark_stmt_modified (stmt); } diff --git a/gcc/tree-stdarg.c b/gcc/tree-stdarg.c index e75e85db753..5dd5d169d67 100644 --- a/gcc/tree-stdarg.c +++ b/gcc/tree-stdarg.c @@ -520,14 +520,14 @@ check_all_va_list_escapes (struct stdarg_info *si) syms_escape_p = false; if (stmt_references_memory_p (stmt)) { - mem_syms_map_t mp = get_loads_and_stores (stmt); - - if (mp->loads - && bitmap_intersect_p (si->va_list_escape_vars, mp->loads)) + if (LOADED_SYMS (stmt) + && bitmap_intersect_p (si->va_list_escape_vars, + LOADED_SYMS (stmt))) continue; - if (mp->stores - && bitmap_intersect_p (si->va_list_escape_vars, mp->stores)) + if (STORED_SYMS (stmt) + && bitmap_intersect_p (si->va_list_escape_vars, + STORED_SYMS (stmt))) continue; } diff --git a/gcc/tree-vect-transform.c b/gcc/tree-vect-transform.c index 50a21cc4e9d..1c91b9d1b2c 100644 --- a/gcc/tree-vect-transform.c +++ b/gcc/tree-vect-transform.c @@ -2320,7 +2320,6 @@ vectorizable_store (tree stmt, block_stmt_iterator *bsi, tree *vec_stmt) def_operand_p def_p; tree def, def_stmt; enum vect_def_type dt; - mem_syms_map_t mp; stmt_vec_info prev_stmt_info; tree dataref_ptr = NULL_TREE; int nunits = TYPE_VECTOR_SUBPARTS (vectype); |