GCC Middle and Back End API Reference
|
Data Structures | |
struct | expr |
struct | expr_hasher |
struct | occr |
struct | unoccr |
struct | modifies_mem |
Variables | |
struct { | |
int moves_inserted | |
int copies_inserted | |
int insns_deleted | |
} | stats |
static hash_table< expr_hasher > | expr_table |
static struct obstack | expr_obstack |
static struct obstack | occr_obstack |
static struct obstack | unoccr_obstack |
static int * | reg_avail_info |
static struct modifies_mem * | modifies_mem_list |
static struct obstack | modifies_mem_obstack |
static struct modifies_mem * | modifies_mem_obstack_bottom |
static int * | uid_cuid |
static int | mems_conflict_p |
|
static |
Helpers for memory allocation/freeing.
Allocate memory for the CUID mapping array and register/memory tracking tables.
References hash_table< Descriptor, Allocator >::create(), expr_obstack, get_max_uid(), occr::insn, modifies_mem_obstack, occr_obstack, uid_cuid, and unoccr_obstack.
Referenced by gcse_after_reload_main().
|
static |
Referenced by eliminate_partially_redundant_loads().
|
static |
Return nonzero if the predecessors of BB are "well behaved".
References cfun, edge_def::flags, function::has_nonlocal_label, basic_block_def::preds, edge_def::src, and tablejump_p().
|
static |
Create hash table of memory expressions available at end of basic blocks. Basically you should think of this hash table as the representation of AVAIL_OUT. This is the set of expressions that is generated in a basic block and not killed before the end of the same basic block. Notice that this is really a local computation.
References hash_scan_set(), modifies_mem::insn, record_opr_changes(), reset_opr_set_tables(), and SET.
Referenced by gcse_after_reload_main().
|
static |
References delete_redundant_insns_1(), dump_file, and hash_table< Descriptor, Allocator >::traverse().
Referenced by gcse_after_reload_main().
int delete_redundant_insns_1 | ( | ) |
Go over the expression hash table and delete insns that were marked for later deletion.
This helper is called via htab_traverse.
References expr::avail_occr, dbg_cnt(), delete_insn(), occr::deleted_p, dump_file, exprs, occr::insn, occr::next, print_rtl_single(), and stats.
Referenced by delete_redundant_insns().
int dump_expr_hash_table_entry | ( | ) |
Dump all expressions and occurrences that are currently in the expression hash table to FILE.
This helper is called via htab_traverse.
References expr::avail_occr, expr::expr, exprs, expr::hash, occr::insn, occr::next, print_rtl(), and print_rtl_single().
Referenced by dump_hash_table().
|
static |
|
static |
|
static |
The work horses of this pass.
This handles the case where several stores feed a partially redundant load. It checks if the redundancy elimination is possible and if it's worth it. Redundancy elimination is possible if, 1) None of the operands of an insn have been modified since the start of the current basic block. 2) In any predecessor of the current basic block, the same expression is generated. See the function body for the heuristics that determine if eliminating a redundancy is also worth doing, assuming it is possible.
References expr::avail_occr, constrain_operands(), copy_insn(), copy_rtx(), edge_def::count, delete_insn(), occr::deleted_p, edge_def::dest, dump_file, extract_insn(), gen_move_insn(), get_avail_load_store_reg(), get_bb_avail_insn(), basic_block_def::index, insert_insn_on_edge(), occr::insn, unoccr::insn, occr::next, unoccr::next, optimize_bb_for_size_p(), unoccr::pred, basic_block_def::preds, print_rtl(), print_rtl_single(), profile_info, reg_changed_after_insn_p(), reg_killed_on_edge(), reg_set_between_p(), reg_used_between_p(), reg_used_on_edge(), set_noop_p(), edge_def::src, stats, targetm, and unoccr_obstack.
Referenced by eliminate_partially_redundant_loads().
|
static |
Performing the redundancy elimination as described before.
References bb_has_well_behaved_predecessors(), function::can_throw_non_call_exceptions, cfun, commit_edge_insertions(), eliminate_partially_redundant_load(), expr::expr, general_operand(), unoccr::insn, lookup_expr_in_table(), may_trap_p(), basic_block_def::next_bb, oprs_unchanged_p(), optimize_bb_for_size_p(), record_opr_changes(), reset_opr_set_tables(), SET, and side_effects_p().
Referenced by gcse_after_reload_main().
DEST is the output of an instruction. If it is a memory reference, and possibly conflicts with the load found in DATA, then set mems_conflict_p to a nonzero value.
References mems_conflict_p, and true_dependence().
Referenced by load_killed_in_block_p().
|
static |
Free memory allocated by alloc_mem.
References hash_table< Descriptor, Allocator >::dispose(), expr_obstack, free(), modifies_mem_obstack, occr_obstack, uid_cuid, and unoccr_obstack.
Referenced by gcse_after_reload_main().
|
static |
References cfun, and optimize_function_for_speed_p().
|
static |
Main entry point of the GCSE after reload - clean some redundant loads due to spilling.
References alloc_mem(), cfun, compute_hash_table(), delete_redundant_insns(), dump_file, dump_hash_table(), hash_table< Descriptor, Allocator >::elements(), eliminate_partially_redundant_loads(), end_alias_analysis(), free_mem(), init_alias_analysis(), memset(), statistics_counter_event(), and stats.
Referenced by rest_of_handle_gcse2().
Referenced by eliminate_partially_redundant_load().
|
static |
Return the loaded/stored register of a load/store instruction.
|
staticread |
Referenced by eliminate_partially_redundant_load().
|
staticread |
Search for the occurrences of expression in BB.
References occr::insn, and occr::next.
|
static |
Hash expression X. DO_NOT_RECORD_P is a boolean indicating if a volatile operand is found or if the expression contains something we don't want to insert in the table.
References hash_rtx().
|
static |
Hash table support.
|
static |
|
static |
Scan the pattern of INSN and add an entry to the hash TABLE. After reload we are interested in loads/stores only.
References can_copy_p(), general_operand(), insert_expr_in_table(), load_killed_in_block_p(), oprs_unchanged_p(), and set_noop_p().
|
static |
Insert expression X in INSN in the hash TABLE. If it is already present, record it as the last occurrence in INSN's basic block.
References expr::avail_occr, occr::deleted_p, expr::expr, expr_obstack, hash_table< Descriptor, Allocator >::find_slot_with_hash(), expr::hash, hash_expr(), occr::insn, occr::next, and occr_obstack.
|
static |
|
static |
Return nonzero if the expression in X (a memory reference) is killed in the current basic block before (if AFTER_INSN is false) or after (if AFTER_INSN is true) the insn with the CUID in UID_LIMIT. This function assumes that the modifies_mem table is flushed when the hash table construction or redundancy elimination phases start processing a new basic block.
References find_mem_conflicts(), modifies_mem::insn, mems_conflict_p, modifies_mem_list, modifies_mem::next, and note_stores().
Referenced by eliminate_partially_redundant_loads().
|
staticread |
Lookup pattern PAT in the expression hash table. The result is a pointer to the table entry, or NULL if not found.
References expr::avail_occr, expr::expr, expr_obstack, hash_table< Descriptor, Allocator >::find_slot_with_hash(), expr::hash, and hash_expr().
rtl_opt_pass* make_pass_gcse2 | ( | ) |
Support for hash table construction and transformations.
|
static |
Return nonzero if the operands of expression X are unchanged 1) from the start of INSN's basic block up to but not including INSN if AFTER_INSN is false, or 2) from INSN to the end of INSN's basic block if AFTER_INSN is true.
References load_killed_in_block_p(), oprs_unchanged_p(), and reg_changed_after_insn_p().
|
static |
|
static |
Record memory modification information for INSN. We do not actually care about the memory location(s) that are set, or even how they are set (consider a CALL_INSN). We merely need to record which insns modify memory.
References modifies_mem::insn, modifies_mem_list, modifies_mem_obstack, and modifies_mem::next.
|
inlinestatic |
Record register first/last/block set information for REGNO in INSN.
|
static |
Referenced by record_last_set_info(), and record_opr_changes().
|
inlinestatic |
|
static |
Called from compute_hash_table via note_stores to handle one SET or CLOBBER in an insn. DATA is really the instruction in which the SET is taking place.
References push_operand(), record_last_mem_set_info(), record_last_reg_set_info(), and record_last_reg_set_info_regno().
|
static |
Referenced by compute_hash_table(), and eliminate_partially_redundant_loads().
|
static |
Record things set by INSN. This data is used by oprs_unchanged_p.
References note_stores(), record_last_mem_set_info(), record_last_reg_set_info(), record_last_reg_set_info_regno(), and record_last_set_info().
|
static |
Return true if register X is recorded as being set by an instruction whose CUID is greater than the one given.
Referenced by eliminate_partially_redundant_load(), and oprs_unchanged_p().
Helpers for eliminate_partially_redundant_load.
|
static |
Check if register REG is killed in any insn waiting to be inserted on edge E. This function is required to check that our data flow analysis is still valid prior to commit_edge_insertions.
References modifies_mem::insn, edge_def::insns, edge_def::edge_def_insns::r, and reg_set_p().
Referenced by eliminate_partially_redundant_load().
|
static |
Similar to above - check if register REG is used in any insn waiting to be inserted on edge E. Assumes no such insn can be a CALL_INSN; if so call reg_used_between_p with PREV(insn),NEXT(insn) instead of calling reg_overlap_mentioned_p.
References modifies_mem::insn, edge_def::insns, edge_def::edge_def_insns::r, and reg_overlap_mentioned_p().
|
static |
Reset tables used to keep track of what's still available since the start of the block.
References memset(), and modifies_mem_obstack.
Referenced by compute_hash_table(), and eliminate_partially_redundant_loads().
|
static |
References gcse_after_reload_main(), get_insns(), and rebuild_jump_labels().
int copies_inserted |
|
static |
Referenced by alloc_mem(), free_mem(), insert_expr_in_table(), and lookup_expr_in_table().
|
static |
The table itself.
int insns_deleted |
|
static |
Used for communication between find_mem_conflicts and load_killed_in_block_p. Nonzero if find_mem_conflicts finds a conflict between two memory references. This is a bit of a hack to work around the limitations of note_stores.
Referenced by find_mem_conflicts(), and load_killed_in_block_p().
|
static |
Referenced by load_killed_in_block_p(), and record_last_mem_set_info().
|
static |
The modifies_mem structs also go on an obstack, only this obstack is freed each time after completing the analysis or transformations on a basic block. So we allocate a dummy modifies_mem_obstack_bottom object on the obstack to keep track of the bottom of the obstack.
Referenced by alloc_mem(), free_mem(), record_last_mem_set_info(), and reset_opr_set_tables().
|
static |
int moves_inserted |
|
static |
Referenced by alloc_mem(), free_mem(), and insert_expr_in_table().
|
static |
Array where each element is the CUID if the insn that last set the hard register with the number of the element, since the start of the current basic block. This array is used during the building of the hash table (step 1) to determine if a reg is killed before the end of a basic block. It is also used when eliminating partial redundancies (step 2) to see if a reg was modified since the start of a basic block.
struct { ... } stats |
@verbatim Post reload partially redundant load elimination
Copyright (C) 2004-2013 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/.
The following code implements gcse after reload, the purpose of this pass is to cleanup redundant loads generated by reload and other optimizations that come after gcse. It searches for simple inter-block redundancies and tries to eliminate them by adding moves and loads in cold places. Perform partially redundant load elimination, try to eliminate redundant loads created by the reload pass. We try to look for full or partial redundant loads fed by one or more loads/stores in predecessor BBs, and try adding loads to make them fully redundant. We also check if it's worth adding loads to be able to delete the redundant load. Algorithm: 1. Build available expressions hash table: For each load/store instruction, if the loaded/stored memory didn't change until the end of the basic block add this memory expression to the hash table. 2. Perform Redundancy elimination: For each load instruction do the following: perform partial redundancy elimination, check if it's worth adding loads to make the load fully redundant. If so add loads and register copies and delete the load. 3. Delete instructions made redundant in step 2. Future enhancement: If the loaded register is used/defined between load and some store, look for some other free register between load and all its stores, and replace the load with a copy from this register to the loaded register.
Keep statistics of this pass.
Referenced by delete_redundant_insns_1(), eliminate_partially_redundant_load(), gather_caller_stats(), gcse_after_reload_main(), and ggc_print_common_statistics().
|
static |
Mapping of insn UIDs to CUIDs. CUIDs are like UIDs except they increase monotonically in each basic block, have no gaps, and only apply to real insns.
Referenced by alloc_mem(), and free_mem().
|
static |
Referenced by alloc_mem(), eliminate_partially_redundant_load(), and free_mem().