GCC Middle and Back End API Reference
equiv_hash_elt Struct Reference
Collaboration diagram for equiv_hash_elt:

Data Fields

tree value
vec< treeequivalences

Detailed Description

Translating out of SSA sometimes requires inserting copies and constant initializations on edges to eliminate PHI nodes.

In some cases those copies and constant initializations are redundant because the target already has the value on the RHS of the assignment.

We previously tried to catch these cases after translating out of SSA form. However, that code often missed cases. Worse yet, the cases it missed were also often missed by the RTL optimizers. Thus the resulting code had redundant instructions.

This pass attempts to detect these situations before translating out of SSA form.

The key concept that this pass is built upon is that these redundant copies and constant initializations often occur due to constant/copy propagating equivalences resulting from COND_EXPRs and SWITCH_EXPRs.

We want to do those propagations as they can sometimes allow the SSA optimizers to do a better job. However, in the cases where such propagations do not result in further optimization, we would like to "undo" the propagation to avoid the redundant copies and constant initializations.

This pass works by first associating equivalences with edges in the CFG. For example, the edge leading from a SWITCH_EXPR to its associated CASE_LABEL will have an equivalency between SWITCH_COND and the value in the case label.

Once we have found the edge equivalences, we proceed to walk the CFG in dominator order. As we traverse edges we record equivalences associated with those edges we traverse.

When we encounter a PHI node, we walk its arguments to see if we have an equivalence for the PHI argument. If so, then we replace the argument.

Equivalences are looked up based on their value (think of it as the RHS of an assignment). A value may be an SSA_NAME or an invariant. We may have several SSA_NAMEs with the same value, so with each value we have a list of SSA_NAMEs that have the same value. Main structure for recording equivalences into our hash table.


Field Documentation

vec<tree> equiv_hash_elt::equivalences

List of SSA_NAMEs which have the same value/key.

Referenced by uncprop_into_successor_phis().

tree equiv_hash_elt::value

The value/key of this entry.


The documentation for this struct was generated from the following file: