patch: make instcombine remove shuffles by reordering vector elements

Nadav Rotem nrotem at apple.com
Fri May 3 23:43:13 PDT 2013


Hi Nick, 

Thanks for working on this.  In this patch you are creating new shuffles with new masks.  We discussed this issue on the mailing list last week. The current design decision in LLVM is that we don't generate new shuffle nodes because of two reasons: cost model and optimization issues. We can't predict if the cost of the new shuffle is lower than the existing one. New shuffles can potentially be very difficult to lower. For example, AVX forbids cross-lane shuffles. We also discussed why merging shuffles can't be reversed in the codegen. Are you trying to solve a particular problem with this patch ? Maybe there are other ways to solve this without introducing new shuffles.

The LoopVectorizer only generates two kinds of shuffles: Reverse and Broadcast, which have target hooks for cost estimation in TTI.  So I am not expecting this patch to affect it.  The SLP Vectorizer does not generate shuffles at the moment. But the plan is to shuffle only loads (this is also what GCC does AFAIK), so I don't think that it would benefit the SLP Vectorizer. 

Thanks,
Nadav 




On May 3, 2013, at 11:00 PM, Nick Lewycky <nicholas at mxc.ca> wrote:

> This patch teaches instcombine to detect cases where we can change the construction of a vector to change the order of the elements, and consequently remove the need for a shufflevector operation later on. Please review!
> 
> It would be nice in particular if the folks working on vectorization would try it out. One thing I haven't even tried is matching horizontal operations as a place to start the "can evaluate in different element order?" machinery.
> 
> Nick
> <llvm-shuffle-order-3.patch>_______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130503/3d0a96d5/attachment.html>


More information about the llvm-commits mailing list