GCC Middle and Back End API Reference


static 
@verbatim
Generic partial redundancy elimination with lazy code motion support. Copyright (C) 19982013 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/.
These routines are meant to be used by various optimization passes which can be modeled as lazy code motion problems. Including, but not limited to: * Traditional partial redundancy elimination. * Placement of caller/caller register save/restores. * Load/store motion. * Copy motion. * Conversion of flat register files to a stacked register model. * Dead load/store elimination. These routines accept as input: * Basic block information (number of blocks, lists of predecessors and successors). Note the granularity does not need to be basic block, they could be statements or functions. * Bitmaps of local properties (computed, transparent and anticipatable expressions). The output of these routines is bitmap of redundant computations and a bitmap of optimal placement points.
Edge based LCM routines.
Edge based lcm routines.
Compute expression anticipatability at entrance and exit of each block. This is done based on the flow graph, and not on the predsucc lists. Other than that, its pretty much identical to compute_antinout.
Allocate a worklist array/queue. Entries are only added to the list if they were not already on the list. So the size is bounded by the number of basic blocks.
We want a maximal solution, so make an optimistic initialization of ANTIN.
Put every block on the worklist; this is necessary because of the optimistic initialization of ANTIN above.
Mark blocks which are predecessors of the exit block so that we can easily identify them below.
Iterate until the worklist is empty.
Take the first entry off the worklist.
Do not clear the aux field for blocks which are predecessors of the EXIT block. That way we never add then to the worklist again.
Clear the aux field of this block so that it can be added to the worklist again if necessary.
If the in state of this block changed, then we need to add the predecessors of this block to the worklist if they are not already on the worklist.
Compute the AVIN and AVOUT vectors from the AVLOC and KILL vectors. Return the number of passes we performed to iterate to a solution.
Allocate a worklist array/queue. Entries are only added to the list if they were not already on the list. So the size is bounded by the number of basic blocks.
We want a maximal solution.
Put every block on the worklist; this is necessary because of the optimistic initialization of AVOUT above.
Mark blocks which are successors of the entry block so that we can easily identify them below.
Iterate until the worklist is empty.
Take the first entry off the worklist.
If one of the predecessor blocks is the ENTRY block, then the intersection of avouts is the null set. We can identify such blocks by the special value in the AUX field in the block structure.
Do not clear the aux field for blocks which are successors of the ENTRY block. That way we never add then to the worklist again.
Clear the aux field of this block so that it can be added to the worklist again if necessary.
If the out state of this block changed, then we need to add the successors of this block to the worklist if they are not already on the worklist.
References basic_block_def::aux, bitmap_clear(), bitmap_intersection_of_preds(), bitmap_ior_and_compl(), edge_def::dest, basic_block_def::index, basic_block_def::succs, and worklist.
Referenced by compute_insert_delete(), and free_cprop_mem().

static 
Compute the earliest vector for edge based lcm.

static 
Edge based LCM routines on a reverse flowgraph.
Compute the farthest vector for edge based lcm.

static 
Compute the insertion and deletion points for edge based LCM.
References compute_available(), create_edge_list(), dump_bitmap_vector(), dump_file, edge_list, edge_list::num_edges, print_edge_list(), sbitmap_vector_alloc(), sbitmap_vector_free(), and verify_edge_list().

static 
later(p,s) is dependent on the calculation of laterin(p). laterin(p) is dependent on the calculation of later(p2,p). laterin(ENTRY) is defined as all 0's later(ENTRY, succs(ENTRY)) are defined using laterin(ENTRY) laterin(succs(ENTRY)) is defined by later(ENTRY, succs(ENTRY)). If we progress in this manner, starting with all basic blocks in the work list, anytime we change later(bb), we need to add succs(bb) to the worklist if they are not already on the worklist. Boundary conditions: We prime the worklist all the normal basic blocks. The ENTRY block can never be added to the worklist since it is never the successor of any block. We explicitly prevent the EXIT block from being added to the worklist. We optimistically initialize LATER. That is the only time this routine will compute LATER for an edge out of the entry block since the entry block is never on the worklist. Thus, LATERIN is neither used nor computed for the ENTRY block. Since the EXIT block is never added to the worklist, we will neither use nor compute LATERIN for the exit block. Edges which reach the EXIT block are handled in the normal fashion inside the loop. However, the insertion/deletion computation needs LATERIN(EXIT), so we have to compute it.
Allocate a worklist array/queue. Entries are only added to the list if they were not already on the list. So the size is bounded by the number of basic blocks.
Initialize a mapping from each edge to its index.
We want a maximal solution, so initially consider LATER true for all edges. This allows propagation through a loop since the incoming loop edge will have LATER set, so if all the other incoming edges to the loop are set, then LATERIN will be set for the head of the loop. If the optimistic setting of LATER on that edge was incorrect (for example the expression is ANTLOC in a block within the loop) then this algorithm will detect it when we process the block at the head of the optimistic edge. That will requeue the affected blocks.
Note that even though we want an optimistic setting of LATER, we do not want to be overly optimistic. Consider an outgoing edge from the entry block. That edge should always have a LATER value the same as EARLIEST for that edge.
Add all the blocks to the worklist. This prevents an early exit from the loop given our optimistic initialization of LATER above.
Note that we do not use the last allocated element for our queue, as EXIT_BLOCK is never inserted into it.
Iterate until the worklist is empty.
Take the first entry off the worklist.
Compute the intersection of LATERIN for each incoming edge to B.
Calculate LATER for all outgoing edges.
If LATER for an outgoing edge was changed, then we need to add the target of the outgoing edge to the worklist.
Computation of insertion and deletion points requires computing LATERIN for the EXIT block. We allocated an extra entry in the LATERIN array for just this purpose.

static 
Compute nearer and nearerout vectors for edge based lcm. This is the mirror of compute_laterin, additional comments on the implementation can be found before compute_laterin.
Allocate a worklist array/queue. Entries are only added to the list if they were not already on the list. So the size is bounded by the number of basic blocks.
Initialize NEARER for each edge and build a mapping from an edge to its index.
We want a maximal solution.
Note that even though we want an optimistic setting of NEARER, we do not want to be overly optimistic. Consider an incoming edge to the exit block. That edge should always have a NEARER value the same as FARTHEST for that edge.
Add all the blocks to the worklist. This prevents an early exit from the loop given our optimistic initialization of NEARER.
Iterate until the worklist is empty.
Take the first entry off the worklist.
Compute the intersection of NEARER for each outgoing edge from B.
Calculate NEARER for all incoming edges.
If NEARER for an incoming edge was changed, then we need to add the source of the incoming edge to the worklist.
Computation of insertion and deletion points requires computing NEAREROUT for the ENTRY block. We allocated an extra entry in the NEAREROUT array for just this purpose.
References basic_block_def::aux.

static 
Compute the insertion and deletion points for edge based LCM.

read 
Given local properties TRANSP, ANTLOC, AVOUT, KILL return the insert and delete vectors for edge based LCM. Returns an edgelist which is used to map the insert vector to what edge an expression should be inserted on.
Compute global availability.
Compute global anticipatability.
Compute earliestness.
Allocate an extra element for the exit block in the laterin vector.

read 
Given local properties TRANSP, ST_AVLOC, ST_ANTLOC, KILL return the insert and delete vectors for edge based reverse LCM. Returns an edgelist which is used to map the insert vector to what edge an expression should be inserted on.
Compute global anticipatability.
Compute farthestness.
Allocate an extra element for the entry block.