scale.score.trans
Class AASR

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

public class AASR
extends Optimization

This class replaces array element address calculations in a loop with simple additions.

$Id: AASR.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.

The array address strength reduction optimization attempts to replace the complex array element address calculation with a simple addition. For example, consider the loop

   for (int i = 0; i < n; i++)
     a(i) =
 
AASR transforms this to
   int *add = &a[0];
   for (int i = 0; i < n; i++) {
     *add =
     add = ((char *) add) + sizeof(int);
   }
 
which eliminates the multiplication, of the loop induction variable by the size of the array element, which would normally occur on each iteration. Arrays of higher rank result in even more savings because their array element address calculation requires more multiplies and additions.

Note that if the array is referenced in the loop in some manner that can't be transformed, then register pressure has been increased by one register (e.g., add). And, even though the induction variable is no longer referenced for each array access, it is still needed for the loop termination test.

A transformation is legal if:

It is beneficial if:


Field Summary
static boolean classTrace
          True if traces are to be performed.
static int maxLoopSize
          Maximum loop size in CFG nodes.
static boolean useHeuristics
          If true, use heuristics that prune the cases where the optimization is applied.
static boolean useSizeof
          Set true to use the sizeof() instead of the machine specific array element size in addressable units.
 
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
AASR(Scribble scribble)
           
 
Method Summary
static int newCFGNodes()
          Return the number of new nodes created.
 void perform()
          Do strength reduction of array accesses.
static int replaced()
          Return the current number of array loads replaced.
 
Methods inherited from class scale.score.trans.Optimization
assertTrace, assertTrace, assertTrace, assertTrace, assertTrace, genTemp, insertStores, requiresSSA, 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.


useSizeof

public static boolean useSizeof
Set true to use the sizeof() instead of the machine specific array element size in addressable units.


maxLoopSize

public static int maxLoopSize
Maximum loop size in CFG nodes.

Constructor Detail

AASR

public AASR(Scribble scribble)
Method Detail

replaced

public static int replaced()
Return the current number of array loads replaced.


newCFGNodes

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


perform

public void perform()
Do strength reduction of array accesses.

Specified by:
perform in class Optimization