[llvm-dev] Extending SLP Vectorizer to deal with aggregates?

Arnold Schwaighofer via llvm-dev llvm-dev at lists.llvm.org
Wed Oct 14 13:44:48 PDT 2015


I don’t see anything that is special to Julia in your example. I think this can be part of the SLPVectorizer. 

It will need a pattern to start its tree building when it sees a store of array of insert values:

partial_value = insert_value(v1 ...)
full_value = insert_value(v2, partial_value)
store [2 x double] full_value, dest

Start a tree at (v1,v2).

A peephole to merge 

partial_value = insert_value(extract_element(v, 0), undef)
full_value = insert_value(extract_element(v, 1), partial_value)
store [2 x double] full_value, dest

into

store <2 x double> v, dest

And adjust the cost modeling in the SLPVectorizer to account for this peephole.


> On Oct 14, 2015, at 8:40 AM, Robison, Arch via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> I’m looking for a sanity check on extending SLP Vectorizer to deal with aggregates. 
>  
> I’d like to vectorize Julia tuple operations.  The Julia compiler lowers tuples to LLVM arrays, not LLVM vectors.  I’ve tried making Julia lower tuples to LLVM vectors, but that hurt performance when SLP Vectorizer was not applicable, because of extraction/insertion overhead.  I.e., the Julia lowering is too early to make the right choice on vector vs. array representation of tuples.  So instead I’d like to make SLP Vectorizer vectorize idioms involving aggregates.  A sample of the idiom is at https://gist.github.com/ArchRobison/e762cd55b8cfc0e019a3 .  
>  
> 1. Identify stores of arrays.  E.g. “store [4 x float]”. 
> 2. Walk chains backwards from the array stores, similar to the way SLPVectorizer already walks chains.
> 3. If vectorization is applicable, replace array construction/load/store with vector construction/load/store.  Vector load/stores will be unaligned.
>  
> Does this sound like a reasonable approach?  If it sounds too Julia-specific, I could do it as a custom Julia pass.
>  
> - Arch D. Robison
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev



More information about the llvm-dev mailing list