[LLVMdev] Area for improvement

Vikram Adve vadve at cs.uiuc.edu
Mon Feb 21 20:18:04 PST 2005


>
>  Now the problem is obvious.  A two dimensional array access is being 
> performed by a single instruction.  The arithmetic needed to address 
> the element is implicit, and therefore inaccessible to optimizations.  
> The redundant calculations can not be eliminated, nor can strength 
> reduction be performed.  getelementptr needs to be broken down into 
> its constituent operations at some point.

Jeff,

This is exactly right -- any multi-dimensional array indexing 
operations need to decomposed into a sequence of single index 
operations so that they can be exposed to GCSE and LICM.  This 
transformation obscures the indexing behavior of the code, so the right 
place to do this is within each back-end, on LLVM code just before 
instruction selection.

There is a pass called DecomposeMultiDimRefs (which seems to have been 
incorrectly moved to lib/Target/SparcV9/) which does this 
transformation.  It's used by the SparcV9 back end before instr. 
selection but is not specific to Sparc.  Running this, followed by LICM 
and GCSE should address this problem.

--Vikram





More information about the llvm-dev mailing list