public class ConditionalEliminationPhase extends BasePhase<CoreProviders>
StructuredGraph. This is done by optimizing
LogicNodes to be conditionally (flow-sensitive) true or false. If such a
condition is input to a control split node, i.e., an IfNode a subsequent application of
the CanonicalizerPhase can remove the unconditional branch from the graph.
In order to prove conditions this phase build the
Dominator Tree of a method
and traverses it depth first. Every time the traversal encounters a basic block whose predecessor
has multiple successors (i.e., the predecessor block ends with a control flow split node) it
inspects the control split's condition in detail: The condition leading to the current block
carries value & type information for the operands of the condition.
Consider the following example where a variable a is used in a condition 3 times.
Traversing the dominator tree depth first and recording the value ranges for a after
every condition effectively makes the last condition a == 0 trivially true.
if (a >= 0) {
// a in [0:Integer.MAX_VAL]
if (a < 1) {
// a in [Integer.MIN_VAL,0] && a in [0:Integer.MAX_VAL]
// --> a in [0]
if (a == 0) { // true
}
}
}
| Modifier and Type | Class and Description |
|---|---|
static class |
ConditionalEliminationPhase.Instance |
static class |
ConditionalEliminationPhase.MoveGuardsUpwards |
static class |
ConditionalEliminationPhase.Options |
BasePhase.ApplyScope, BasePhase.BasePhaseStatistics, BasePhase.PhaseOptions, BasePhase.SharedGlobalPhaseState| Constructor and Description |
|---|
ConditionalEliminationPhase(boolean fullSchedule) |
ConditionalEliminationPhase(boolean fullSchedule,
boolean moveGuards) |
| Modifier and Type | Method and Description |
|---|---|
float |
codeSizeIncrease()
Returns a factor
>=1 that determines what the final code size in terms of the sum of
the node code sizes NodeSize of all nodes is. |
protected ControlFlowGraph.RecursiveVisitor<?> |
createVisitor(StructuredGraph graph,
ControlFlowGraph cfg,
BlockMap<List<Node>> blockToNodes,
NodeMap<Block> nodeToBlock,
CoreProviders context) |
protected BlockMap<List<Node>> |
getBlockToNodes(ControlFlowGraph cfg) |
protected void |
run(StructuredGraph graph,
CoreProviders context) |
apply, apply, applyScope, contractorName, equals, getName, hashCode, shouldDumpAfterAtBasicLevel, shouldDumpBeforeAtBasicLevelclone, getClass, notify, notifyAll, toString, wait, wait, waitcheckContractpublic ConditionalEliminationPhase(boolean fullSchedule)
public ConditionalEliminationPhase(boolean fullSchedule,
boolean moveGuards)
protected void run(StructuredGraph graph, CoreProviders context)
run in class BasePhase<CoreProviders>protected BlockMap<List<Node>> getBlockToNodes(ControlFlowGraph cfg)
protected ControlFlowGraph.RecursiveVisitor<?> createVisitor(StructuredGraph graph, ControlFlowGraph cfg, BlockMap<List<Node>> blockToNodes, NodeMap<Block> nodeToBlock, CoreProviders context)
public float codeSizeIncrease()
PhaseSizeContract>=1 that determines what the final code size in terms of the sum of
the node code sizes NodeSize of all nodes is.codeSizeIncrease in interface PhaseSizeContractcodeSizeIncrease in class BasePhase<CoreProviders>