[LLVMdev] Scalar replacement of arrays

Preston Briggs preston.briggs at gmail.com
Fri Mar 9 09:34:14 PST 2012


Nicolas Capens wrote:
> [...]
> I'm not sure if that's going to help achieve optimal code
> for when the array is sometimes being dynamically indexed.
> Essentially there should be some kind of store to load copy
> propagation. As far as I know that's exactly what mem2reg
> does, except that it only considers scalars and not elements
> of arrays.
>
> So would it be hard to extend mem2reg to also consider elements
> of arrays for promotion? It should obviously not perform the promotion
> when in between the store and load there's a dynamically indexed
> access to the array. Correct me if I'm wrong, but that seems it would
> be superior to scalarrepl itself (for arrays).
>
> Is there anyone experienced with mem2reg who wants to implement this?
> If not, any advice on how to best approach this?

Classically, we use dependence analysis to support such optimizations.
For example, see Chapter 8 in Allen & Kennedy's book,
"Optimizing Compilers for Modern Architectures."

Preston



More information about the llvm-dev mailing list