[llvm] r180802 - InstCombine: Fold more shuffles of shuffles.

Nadav Rotem nrotem at apple.com
Tue Apr 30 14:38:51 PDT 2013


On Apr 30, 2013, at 2:23 PM, Jim Grosbach <grosbach at apple.com> wrote:

> That used to be true. These days, we see lots of shuffles coming from SROA and we have to mess with them or things go very badly.  

You can change SROA to reduce the number of shuffle vectors. I scanned SROA and I did not see anything too bad. I only saw insert/extract and blend, which should map nicely to any vector ISA.  But you can make things better by changing SROA.cpp::insertVector to generate a select instruction, instead of a vector shuffle.
 
> The more I think about it, the more I disagree with the current design. It creates a very deep tight coupling between what InstCombine does and the least-common-denominator of what target codegen can handle. That’s untenable in the long term and artificially restrictive.

The motivation for the current design (which I am happy with) is that it is very difficult to undo a canonicalization of shuffles because the search space is huge. Also, the clang shuffle builtins are used by people who optimize their performance sensitive applications. 

We use this approach in other places in the compiler. We don't always canonicalize all the way and in many cases we prefer not to touch the program unless we are certain that the change is beneficial.  The shuffle ISA is so sparse that merging shuffles are likely to cause regressions. 
   

>> When I looked at the test case I noticed that some of your shuffles were actually vector blends. It would make sense to convert blend-shuffles into select instructions with a constant mask.    
>> 
> 
> Sounds like a good idea. I don’t know much about the provenance of the original IR of these test cases.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130430/8deba325/attachment.html>


More information about the llvm-commits mailing list