scale.score.trans
Class UselessCopy

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

public class UselessCopy
extends Optimization

This class removes useless copies from the CFG.

$Id: UselessCopy.java,v 1.17 2007-02-28 18:00:39 burrill Exp $

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

A useless copy is simply the expression var = var;. It is always valid to remove such occurrences.

Unlike most optimizations this optimization never increases register pressure. Consequently, there is never a case where a legal transformation is not also beneficial.


Field Summary
static boolean classTrace
          True if traces are to be performed.
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
UselessCopy(Scribble scribble)
           
 
Method Summary
 void perform()
          Remove useless copy statements.
 int requiresSSA()
          Return whether this optimization requires that the CFG be in SSA form.
static int uselessCopyCFGNodes()
          Return the number of useless copies 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.

Constructor Detail

UselessCopy

public UselessCopy(Scribble scribble)
Method Detail

uselessCopyCFGNodes

public static int uselessCopyCFGNodes()
Return the number of useless copies eliminated.


perform

public void perform()
Remove useless copy statements. Useless copy statements(CFG nodes) are of the form
  X = X;
 
These are created by going into and out of SSA form and by other 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