scale.score.trans
Class BasicBlockOps

java.lang.Object
  extended by scale.score.trans.Optimization
      extended by scale.score.trans.BasicBlockOps

public class BasicBlockOps
extends Optimization

Perform optimizations on each basic block.

$Id: BasicBlockOps.java,v 1.57 2007-10-04 19:58:35 burrill Exp $

Copyright 2008 by the Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.

This module performs optimizations that are local to a basic block. For this module a basic block ends at a function call as well as at a branch point in the CFG. These optimizations do not require use-def links and may be performed in or out of SSA form. Current basic block optimizations:

  1. Eliminate duplicate loads from a structure field.
  2. Eliminate duplicate loads from scalar variables (e.g., global or static scalar variables).
  3. Eliminate duplicate memory address generation.
  4. Eliminate un-needed stores into scalar variables.

Elimination of a store to a variable is legal if:

It is always beneficial.

Eliminating a load increases the live range of any definition of a register value. This increases register pressure.

Elimination of a load from a variable is legal if:

If it is legal, it is always eliminated.

Replacing a reference to a constant with a reference to a variable is legal if the variable has been loaded with the constant value previously in the basic block. It is beneficial if the cost of generating the constant value in a register is greater than minimumExecutionCost.


Field Summary
static boolean classTrace
          True if traces are to be performed.
static int maxBlockSize
          Maximum number of CFG nodes that we will process in one "chunk".
static boolean useHeuristics
          If true, use heuristics that prune the cases where the optimization is applied.
 
Fields inherited from class scale.score.trans.Optimization
dChanged, fpReorder, hasDummyAliases, IN_SSA, minimumExecutionCost, NA_SSA, NO_SSA, rChanged, scribble, signedIntsWrapOnOverflow, trace, un, unsafe, unsignedIntsWrapOnOverflow, VALID_SSA
 
Constructor Summary
BasicBlockOps(Scribble scribble)
           
 
Method Summary
static int constantEliminated()
          Return the number of times the generation of a constant was eliminated.
static int loadAddressEliminated()
          Return the number of times the generation of a memory address was eliminated.
static int loadArrayAddressEliminated()
          Return the number of times the generation of an array element address was eliminated.
static int loadEliminated()
          Return the number of times a load from memory was eliminated.
static int loadFieldAddressEliminated()
          Return the number of times the generation of a structure field address was eliminated.
static int loadFieldEliminated()
          Return the number of times a load from a structure field was eliminated.
static int loadIndirectEliminated()
          Return the number of times a load indirect was eliminated.
static int newCFGNodes()
          Return the number of new nodes created.
 void perform()
          Perform the actual basic block optimizations.
 int requiresSSA()
          Return whether this optimization requires that the CFG be in SSA form.
static int storeEliminated()
          Return the number of times a load from memory was eliminated.
 
Methods inherited from class scale.score.trans.Optimization
assertTrace, assertTrace, assertTrace, assertTrace, assertTrace, genTemp, insertStores, setTrace, sort
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

classTrace

public static boolean classTrace
True if traces are to be performed.


useHeuristics

public static boolean useHeuristics
If true, use heuristics that prune the cases where the optimization is applied.


maxBlockSize

public static int maxBlockSize
Maximum number of CFG nodes that we will process in one "chunk".

Constructor Detail

BasicBlockOps

public BasicBlockOps(Scribble scribble)
Parameters:
scribble - is the CFG
Method Detail

newCFGNodes

public static int newCFGNodes()
Return the number of new nodes created.


loadEliminated

public static int loadEliminated()
Return the number of times a load from memory was eliminated.


constantEliminated

public static int constantEliminated()
Return the number of times the generation of a constant was eliminated.


storeEliminated

public static int storeEliminated()
Return the number of times a load from memory was eliminated.


loadFieldEliminated

public static int loadFieldEliminated()
Return the number of times a load from a structure field was eliminated.


loadIndirectEliminated

public static int loadIndirectEliminated()
Return the number of times a load indirect was eliminated.


loadAddressEliminated

public static int loadAddressEliminated()
Return the number of times the generation of a memory address was eliminated.


loadFieldAddressEliminated

public static int loadFieldAddressEliminated()
Return the number of times the generation of a structure field address was eliminated.


loadArrayAddressEliminated

public static int loadArrayAddressEliminated()
Return the number of times the generation of an array element address was eliminated.


perform

public void perform()
Perform the actual basic block optimizations.

Specified by:
perform in class Optimization

requiresSSA

public int requiresSSA()
Return whether this optimization requires that the CFG be in SSA form. It returns either
NO_SSA
the CFG must not be in SSA form,
IN_SSA
the CFG must be in SSA form,
VALID_SSA
the CFG must be in valid SSA form, or
NA_SSA
the CFG does not need to be in valid SSA form.

Overrides:
requiresSSA in class Optimization