[LLVMdev] Area for improvement

Jeff Cohen jeffc at jolt-lang.org
Mon Feb 21 21:12:15 PST 2005


I figured getelementptr exists as it does to facilitate data flow 
analysis, but it does need to be broken down before instruction 
selection.  It's not just the missed optimization opportunities.  It 
also introduces a huge amount of complexity into instruction selection 
as they deal with its complexity.  It would also take care of many of 
the FIXMEs in LoopStrengthReduce.

Vikram Adve wrote:

>>
>>  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